npm / @better-auth/core
@better-auth/core
What changed in @better-auth/core 1, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
48 breaking35 security2 deprecations48 new APIs and options4 performance22 behavior and defaults61 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@better-auth/core 1220 changes
Breaking changes 48
IPv6 addresses are public only within global unicast
2000::/3, except NAT64 addresses whose embedded IPv4 address is public; other previously public-classified ranges are reserved.Introspected active tokens that fail configured aud, iss, exp, or nbf checks now produce a 401 UNAUTHORIZED error instead of a plain Error that can lead resource servers to answer with a 500.
With serial ID generation, filtering an id or reference field with null now compares it with null instead of converting null to 0.
For a non-loopback HTTP issuer configured with
baseURLorjwt.issuer, discovery and theissauthorization response parameter now report the configured issuer instead of rewriting it to HTTPS.Client registration and updates now reject post-logout redirect URIs containing credentials, matching the existing rule for redirect URIs.
When an authorization request uses a registered HTTP redirect URI rejected by the HTTPS policy, the error is shown on the server error page rather than redirected to that URI.
getAccessToken and refreshToken now fail when a provider refuses a token refresh with a 200 status, rather than returning the expired access token.
Account linking and new OAuth users count email as verified only when the provider claim is true or the string "true"; other values read as unverified.
Direct ID-token sign-in and linking resolve the profile from the verified ID token only, ignoring submitted access or refresh tokens.
Generic OAuth providers with a discovery document containing jwks_uri reject profiles whose sub differs from the ID token's sub.
Built-in social providers no longer follow HTTP redirects on token exchange, refresh, verification, and JWKS requests, matching other server-side OAuth requests.
Rejects ID tokens when the provider has no client ID, so their audience can be checked. Set clientId to every client ID your apps sign in with.
ID tokens missing exp or iat are now rejected.
Custom Paybin issuers must expose RS256 signing keys at the issuer's JWKS endpoint.
A key-set fetch taking longer than 5 seconds now fails with a JWKSTimeout error instead of waiting indefinitely.
Unreachable key sets now throw errors instead of making tokens appear invalid; with remoteVerify configured, failures no longer fall back to remote introspection.
Microsoft ID-token verification treats signing keys without an alg field as RS256 and rejects Microsoft ID tokens signed with any other algorithm.
Refuses to apply changes when required columns that Better Auth never writes need manual repair.
Initialization checks schema objects and models, reports missing tables or columns and required unwritten columns, and authentication requests await the check and are rejected if the schema does not match.
The account issuer requirement introduced in 1.7.0 is removed; upgrades from 1.6 no longer require an account schema migration, though databases with the 1.7.0–1.7.2 schema need cleanup.
The resource-request input type is renamed to ResourceRequestInput.
Account identity is now unique by issuer and accountId, so aliases for one OIDC issuer deduplicate while equal subjects from different issuers remain separate; a reviewed backfill is required.
Run a schema migration to add the confirmation column to access-token and refresh-token tables for DPoP token binding.
The synchronous OAuth2 request builder is removed; use the async authorizationCodeRequest helper instead.
Replace the experimental joins setting with advanced.database.joins.
Providers declare an idToken configuration for shared signature, issuer, audience, and nonce verification; providers without one reject client-submitted id_token sign-in.
Rejects deprecated IPv4-compatible IPv6, the 6to4 relay anycast prefix, and deprecated site-local IPv6 addresses so SSRF gates reject these non-public hosts.
OAuth client JWKS metadata must now be an RFC 7517 JWK Set object with a non-empty keys array, including remotely fetched jwks_uri responses.
SSO account subjects now come from protocol-defined OIDC sub or signed SAML NameID claims, so mapping.id is removed.
The mapper can no longer return id; read the selected provider identity from accountInfo.account.accountId instead of accountInfo.user.id.
The Generic OAuth helper now requires a concrete tenant GUID; use the built-in Microsoft provider for multi-tenant authorities.
Microsoft sign-in now identifies Entra accounts using the stable oid claim and rejects tokens without a valid oid; existing Microsoft account rows created from sub must be migrated.
SCIM is replaced with provisioning into application-defined domains, including Users, Groups, direct memberships, validated custom-role projections, and SCIM 2.0 features; existing installations require full directory reprovisioning.
The raw-token verifier is renamed to verifyBearerToken and rejects DPoP-bound tokens; use verifyAccessTokenRequest on endpoints that may receive them.
Custom UpstreamProvider implementations replace the removed verifyIdToken method with an idToken config.
Returns null when no row matches or when called without a predicate. Kysely MySQL guarded updates and Prisma guarded updates now follow this behavior; use updateMany for intentional bulk updates.
Rate limiting no longer trusts multi-hop X-Forwarded-For chains. Set trusted proxy IPs or CIDR ranges to identify the real client by walking the chain right to left and skipping trusted hops.
Rejects redirect and callback targets that are not in trustedOrigins.
Rate limiting is enforced even when a client IP cannot be determined, instead of being skipped.
Rejects additional reserved IPv6 ranges.
Opaque access tokens are checked through Facebook's debug_token endpoint for validity, a configured client ID, and a matching profile user ID. Access-token sign-in now requires a client secret.
When configured, the hosted-domain option must match the verified ID token and decoded callback profile; otherwise sign-in is rejected.
Reddit no longer uses the OAuth application ID as a user's email or marks it verified. It uses the mapped email when provided, otherwise a unique synthetic address; provide a real email through mapProfileToUser.
Remote introspection now rejects tokens when a required audience is missing or mismatched, rather than skipping audience validation when the response omits aud.
Rejects redirect URIs that contain a fragment component, per RFC 6749 §3.1.2.
Validates options at construction; unsupported algorithms, missing JWK key material, or disagreement between explicit and JWK algorithms now throw eagerly.
Redirect URI validation uses a try/catch parsing fallback instead of URL.canParse and rejects URIs containing fragments.
Providers reject empty arrays, empty strings, and missing configuration at sign-in time; Google, Apple, and Facebook also require clientSecret, while Microsoft Entra and Cognito require only clientId.
Security 35
Replay reservations last one second past the proof's accepted window, preventing reuse during the final second; this applies to in-memory, database, and secondary-storage stores.
Kakao sign-in now uses PKCE, sending a code challenge in the authorization request and a verifier in the token request.
Used proofs are recorded in secondary storage, so DPoP works when verification values are stored there and replayed proofs remain rejected across instances.
Failed fallback join queries are reported only through the configured logger, avoiding raw database errors with SQL and bound values being printed to the console.
Accepts { cause } as a third argument, preserving the underlying error for server-side callers without exposing it in the response.
A custom Facebook getUserInfo no longer receives client-submitted access tokens issued to another Facebook app.
Twitch and Paybin sign-in verify ID token signatures and identity claims before mapping profiles, with 30 seconds of clock tolerance.
When session revocation is requested, password changes and resets save the password and revoke database sessions in one transaction when supported. onPasswordReset runs after sessions are revoked; secondary-storage removal remains best-effort after commit.
Single-use checks work with advanced.database.generateId: "uuid" on SQLite and MySQL; SAML assertions, DPoP proofs, and client assertions are accepted only once on Postgres and MongoDB. With "serial", Better Auth warns that these checks need string IDs.
Token requests use OAuth-compliant Basic authentication and add redirect protection.
@better-auth/drizzle-adapter: Concurrent requests can exceed rate limits on PostgreSQL
CIMD follows shared-cache freshness rules, prefers s-maxage, conditionally revalidates, and fails closed when freshness is ambiguous.
This helper converts insufficient-scope signals and recognized token failures into safe RFC 6750 challenges.
Node.js deployments can import a secure transport that resolves once, rejects non-public DNS answers, pins the approved connection, and returns redirects and bodies without buffering.
CIMD fetches can be governed by coalescing, pacing, concurrency limits, and rolling 60-second budgets to bound metadata request amplification.
OAuth providers can opt in to withholding sessions for unverified provider emails; callback, ID token, and One Tap flows return the documented errors.
This provisioning gate can reject an identity before user creation or account linking, and revalidates returning OAuth or SSO sign-ins with fresh provider profile data.
Resource servers can verify DPoP requests, including the Authorization scheme, proof, request target, access-token hash, and replay; it uses a database-backed verification store by default.
Apple OAuth authorization now sends PKCE code challenges so callback token exchanges include a matching code verifier.
@better-auth/scim: account takeover and stale access via SCIM provider-id collision
HTTP redirects are refused for server-side OAuth token exchange, token refresh, client-credentials, token introspection, and JWKS requests, preventing redirects to unintended internal addresses.
@better-auth/stripe: cross-organization billing tampering in organization subscription actions
Applies the configured Google hosted-domain restriction before creating a session.
Google reCAPTCHA and Cloudflare Turnstile accept this optional setting to reject tokens minted for a different hostname.
Google reCAPTCHA and Cloudflare Turnstile accept this optional setting to reject tokens minted for a different action.
Adds an atomic single-use marker operation so exactly one concurrent caller succeeds; database-backed verification storage is atomic, while secondary-storage-only verification is best-effort.
Concurrent requests can no longer slip past the configured limit, enforcement is no longer skipped when a client IP cannot be determined, and the in-memory store no longer grows without bound; the database backend removes expired entries automatically.
Malformed redirect parameters now return a 400 instead of a 500.
Microsoft Entra ID sign-in now enforces tenant restrictions: organizations rejects personal accounts, and consumers rejects work and school accounts.
The cache is scoped per JWKS source and honors a TTL, preventing keys from another source from being reused and ensuring rotated or removed keys stop being used after the TTL.
Direct sign-in now cryptographically verifies ID tokens using PayPal's issuer and JWKS or the client secret, checks the configured client ID as audience, bounds token age, and checks the nonce when supplied.
OAuth provider plugins now parse URLs with a try/catch fallback instead of URL.canParse, avoiding failures or disabled dangerous-scheme checks on some supported runtimes.
Per-request authorization parameters are accepted by signIn.social, linkSocial, and signIn.sso; reserved security-sensitive keys are rejected or filtered.
Direct callers receive the same validation for unsupported algorithms, missing JWK key material, and algorithm disagreement.
OAuth 2.1 Provider: Unprivileged users can register OAuth clients
Deprecations 2
The existing option is deprecated but remains supported for backward compatibility.
Remains available as a deprecated compatibility API.
New APIs and options 48
clientIdaccepts an array to include the native app key for Kakao ID token sign-in.Social providers can return values for fields declared in
account.additionalFields; Better Auth saves them when an account is created, linked, or updated at sign-in.The function now accepts the auth context and picks the same storage.
Accepts an optional headers input for providers that need extra headers on access-token refresh; client authentication headers take precedence.
Allows controlled origins to use HTTP redirect URIs, including localhost callbacks during development; without it, redirect URI validation is unchanged.
The Cloudflare provider accepts tokenEndpointAuth with a method field for configuring token endpoint authentication.
The Vercel social provider can configure token endpoint authentication, including dynamic OIDC tokens and private key JWT client assertions, without replacing the built-in sign-in flow.
This option lets dynamic registration infer native when application_type is omitted and a custom-scheme redirect URI is present, or treat omitted application_type as native. The default remains web.
Adds a schema option for direct PostgreSQL connections; the adapter and CLI qualify statements with it, and auth generate creates the schema before its tables.
Add an option to disable Better Auth OpenTelemetry span creation per auth instance; instrumentation remains enabled by default and independent of usage reporting.
Cloudflare is available as a built-in social provider, supporting client-secret authentication and PKCE clients without a secret.
Providers that require non-standard request parameters can use a custom strategy to authenticate token endpoint requests.
Provides synchronous access to the current auth endpoint context.
Provides optional access to the current auth endpoint context.
Account-specific APIs use accountId to select the local Account.id; token and provider-profile APIs can select the signed account cookie with useAccountCookie.
signIn.social, linkSocial, and signIn.sso accept per-request authorization URL parameters; Generic OAuth merges them with configured parameters, with call-time values winning collisions.
Use this helper when an operation determines its required scopes dynamically.
This helper signs RFC 7523 assertions from a private key, with client ID, token endpoint, and grant type supplied to the assertion getter.
Set this option to true to keep sign-out local instead of logging out from the configured provider.
Resources can require DPoP-bound access tokens.
Enables providers that initiate OAuth without a
stateparameter; stateless callbacks restart the flow server-side with fresh state and PKCE.Manual SAML configurations without metadata XML must set this IdP identity; samlConfig.issuer identifies the service provider instead.
The Google provider option controls whether
include_granted_scopes=trueis included in the authorization URL; it defaults totrue, and call-timeadditionalParamscan override it.Provide this function to define hierarchical scope policies instead of the default exact membership check.
The Microsoft Entra ID social provider supports
clientAssertion.The exported header set lets developers add no-store and no-cache headers to hand-built credential-bearing responses.
Generic OAuth refresh requests can include extra body parameters through an object or sync/async function; grant_type and refresh_token cannot be overridden.
Protected MCP scopes can be configured so missing scopes produce an RFC 6750 insufficient_scope challenge naming every missing scope.
Opt-in JWKS-backed asymmetric JWT support lets services verify session cookie-cache tokens with public keys instead of shared secrets.
Plugin database schemas can define named or generated indexes spanning multiple fields, with consistent configured table and column names across migrations and adapters.
Generic OAuth providers can configure token endpoint authentication using private_key_jwt, none, client_secret_basic, or client_secret_post.
The method accepts an optional second context argument, allowing refresh implementations to access request metadata.
Adds a utility for creating stable, namespaced placeholder emails on the reserved placeholder.invalid domain.
Custom ID token verifiers receive the request endpoint context as a third argument, allowing them to read request headers.
Custom rate-limit storage may implement this optional method for strict enforcement; without it, previous behavior remains and a one-time warning is logged.
Adds an optional adapter method that atomically applies signed numeric deltas to one guarded row and returns the updated row or null; adapters without native support use a transaction-based fallback.
Adds an optional method that atomically increments a counter and sets its time-to-live only when the key is first created.
Set this flag to opt back into accepting remote introspection responses that omit aud; mismatching audiences are still rejected.
GenericOAuthConfig and SSO OIDCConfig can enable stateless callbacks; the server restarts the OAuth flow with fresh state and PKCE.
Core OAuth2 exports a decoder that follows RFC credential parsing rules, including case-insensitive scheme handling and optional spaces.
Core OAuth2 exports an RFC 6749-compliant helper for encoding client credentials containing reserved characters.
Cognito exposes a typed option that maps to the identity_provider authorization query parameter.
linkSocial now accepts loginHint, matching the signIn.social and signIn.sso request surfaces.
The input contract gains additionalParams, which built-in providers forward to the shared authorization URL helper.
Accepts an array of Client IDs for Google, Apple, Microsoft Entra, Facebook, and Cognito; the first is used for authorization code flow and all are accepted for ID-token audience verification.
Exports a helper from @better-auth/core/oauth2 that returns the primary Client ID for the authorization code flow.
Adds shared host-classification utilities for loopback, public-routable, and other host checks.
Adds a bounded-concurrency utility, available from @better-auth/core/utils/async.
Performance 4
The default in-memory store no longer scans every proof in the replay window, preventing per-request CPU time from growing with request rate.
The semantic conventions production dependency was removed, reducing installation size while preserving instrumentation attribute keys.
An unknown kid triggers at most one key-set refetch every 30 seconds per server process, and concurrent verifications share that fetch, limiting requests caused by made-up key IDs.
Request IP validation is faster.
Behavior and default changes 22
Kakao ID tokens from native SDKs can now be passed to
signIn.social.Official packages now accept any better-call 1.4 patch release from 1.4.5 as a peer dependency.
Exports the runtime detection used by the package; telemetry now reports Cloudflare Workers as workerd instead of node when nodejs_compat is enabled.
With remoteVerify, active introspection tokens are accepted; local typ verification applies only when jwksUrl is set and remoteVerify.force is not true.
Native OAuth clients and Client ID Metadata Documents can use custom-scheme redirect URIs with a host and path; pairwise clients cannot use these host-bearing URIs.
ID token verification allows 30 seconds of clock difference for exp, nbf, and iat, including tokens up to 30 seconds past exp. Custom verifyIdToken implementations must set their own tolerance.
Schema validation is enabled by default, including in production; set this option to false to disable runtime validation.
Relative callback and redirect URLs can use standard path, query, and fragment syntax while preserving open-redirect protections.
Database joins are now a stable option, disabled by default; enabled adapters use native joins when possible and otherwise fall back to additional queries.
Generic OAuth sign-out can redirect to a configured or discovered provider logout endpoint and include id_token_hint when available; local-only behavior remains configurable.
When configured, OAuth redirect_uri values are built from the current request base URL, supporting multi-host deployments.
Custom OAuthProvider implementations can omit callbackPath when using the shared /callback/<provider-id> route.
Unknown draft-02 metadata members are ignored and never persisted; recognized secrets, privilege fields, and server controls remain fatal.
The helper now forwards resource values to refresh-token requests, supporting RFC 8707 resource indicators.
Google sign-in accepts hd: "*" to allow any Google Workspace hosted domain, while still rejecting tokens with no hosted-domain claim.
The email field is now optional.
The email field is now optional.
The email field is now optional.
The email_verified field is now optional.
OAuth providers that may omit email can now be unblocked by synthesizing an email inside mapProfileToUser; sign-in still rejects if no email is produced.
The email field is now optional.
The package is now an optional peer dependency.
Fixes and other changes 61
Authorization URLs preserve empty query segments, while Better Auth's parameters continue to replace matching endpoint values.
IPv6 addresses with dotted IPv4 tails are no longer misread as IPv4-mapped; the classifier rejects them as reserved, and IP normalization and CIDR matching expand the tail into two hex groups.
The well-known NAT64 block is public when it embeds a public IPv4 address and reserved otherwise, enabling outbound checks for DNS64-resolved names with only an A record.
Existing query text on the authorization endpoint is kept unchanged; parameters set by Better Auth still replace endpoint parameters with the same name.
Reads signing keys from the auth instance instead of its own /jwks request, avoiding failures on runtimes that block requests to their own hostname; set jwksUrl to keep fetching keys over HTTP.
Error descriptions are fitted to the characters allowed by RFC 6750, preventing challenge creation from throwing; invalid scope tokens in challengeScopes still throw.
Session retrieval no longer fails when a user.additionalFields entry references a table outside the Better Auth schema, including with database joins enabled on Drizzle and Prisma.
A 401 Bearer challenge for a token that failed verification now includes error="invalid_token" and an error_description; requests without a token still get no error code.
Generic OAuth providers now send authorizationHeaders when refreshing an access token, not only when exchanging the authorization code.
Client authentication replaces extra headers with names differing only in case, including headers set by a custom tokenEndpointAuth hook, preventing invalid combined headers on code exchange and refresh.
Authentication requests no longer hang if the request that started schema validation ends before validation finishes; each Workers request runs its own schema lookup until one completes.
On Prisma with MongoDB, magic link and email OTP sign-in for users with an unverified email no longer fail with a Malformed ObjectID 500; SAML sign-in, DPoP-bound OAuth requests, and private_key_jwt client authentication are fixed the same way.
Sign-In with Ethereum now keeps the email the user supplied instead of a placeholder.
The Zoom social provider now applies this configured provider option for Zoom sign-ins.
Kakao sign-in now passes loginHint to Kakao, pre-filling the ID field on the Kakao Account login page.
Fixes typechecking under exactOptionalPropertyTypes when the function returns undefined for name, email, or image.
Restores the pre-1.7.11 handling so account info does not fail after the ID token stored at sign-in expires.
Plugins whose init returns options: undefined now typecheck when exactOptionalPropertyTypes is enabled.
On adapters without transactions enabled, after hooks for writes that remain persisted now run even when the request fails after writing data.
With storeSessionInDatabase enabled and preserveSessionInDatabase disabled, cache eviction no longer causes valid device sessions to disappear or automatic session switching to fail.
When passed a client on a replica set, the adapter retries conflicting transactions for up to 120 seconds or until MongoClient timeoutMS. Retried work can repeat, including databaseHooks before hooks and work outside the database before commit.
Sign-up no longer leaves a secondary-storage session after a failed commit. Session listing reads the database in the specified storage configuration; other specified flows keep session writes in their transaction so storage failure rolls back related records.
SIWE sign-in now uses the supplied email when no other account has it, rather than always using the wallet-derived address.
Preserves logical model identity when a custom model name matches another schema key.
Restores database option type inference for projects that do not use Cloudflare Workers.
Bundlers such as Metro no longer fail when the optional OpenTelemetry API is not installed.
Accounts are identified by (providerId, accountId), restoring sign-in compatibility with 1.6 databases without an account schema migration; ambiguous keys are rejected.
For Prisma clients whose model metadata omits nullability, the command reads the existing Prisma schema to report required fields Better Auth never writes.
Custom database adapters may omit this method again; guarded fallbacks require atomic conditional writes and accurate affected-row counts.
Custom database adapters may omit this method again; fallback increments require atomic conditional writes and accurate affected-row counts and can fail when contention exhausts retries.
Authorization code and refresh token requests are improved, including PKCE parameter handling.
Sign-in and token refresh now work when configured with the documented clientKey and clientSecret options.
Prevents async context loss in Cloudflare Workers bundles that enable multiple runtime conditions.
Logs emitted while handling auth requests respect the configured custom logger, log level, and disabled setting.
Built-in placeholder emails consistently use the namespaced
{identifier}@{namespace}.placeholder.invalidformat.Previously granted OAuth scopes are preserved across re-authentication and refresh-token requests; new scopes are merged through
linkSocial, and narrower provider claims no longer shrink the stored value.One Tap, Electron, and Expo client plugins compose without TypeScript errors, while preserving each plugin's inferred actions.
The DPoP algorithm option uses signingAlgorithms everywhere.
Deferred database side effects run only after a successful transaction, preventing rolled-back updates from refreshing cached profiles or invalidating sessions.
Prevents concurrent cold-start requests from intermittently losing authentication or transaction context.
Aligned context types with runtime route parameters, so endpoint and middleware code can reflect the parameters available at runtime.
Response headers are preserved when resolving sessions from endpoint contexts.
Concurrent first-callers now share a memoized in-flight initialization, preventing request-state mismatches on serverless cold starts.
Plugin schema tables flagged with disableMigration: true are skipped by better-auth generate for Drizzle and Prisma output and by the runtime migrator.
Inherited APIError properties are now declared to fix TypeScript inference errors.
Calling incrementOne without increment or set now reports a clear error.
Single-use verification flows no longer hang on database adapters that use a one-connection pool, fixing magic-link verification and similar token checks in connection-limited serverless database setups.
Fixes plugin-provided client methods and additional session fields not being inferred in composite monorepos.
When baseURL is unset, password-reset and verification links use the current request's host rather than the host of the server's first request.
Fixes a memory leak that caused the cache to grow on every access token verification.
Users without email receive a non-routable, unverified placeholder address on reddit.invalid instead of one on the real reddit.com domain; mapProfileToUser can supply a real email.
A request-scoped trustedOrigins callback no longer affects other concurrent requests.
Sign-in now succeeds with the documented default setup despite WeChat returning no email; the user receives a stable, unverified placeholder email, and mapProfileToUser can supply a real one.
When OpenTelemetry is not installed, Cloudflare Workers instrumentation imports are routed to a pure no-op entry.
The adapter factory self-references ./instrumentation so the exports map routes edge and browser environments to the pure variant.
The email field is now typed as string or null and is optional when the email scope is not granted.
The email_verified field is now optional because Meta's Graph API does not include it.
The email field is now typed as string or null.
Preserves accumulated Set-Cookie headers when an endpoint throws APIError, so cookie side-effects are not discarded on the error path.
Serves a noop instrumentation module under browser and edge conditions, matching ./async_hooks.
Redirect APIErrors are no longer recorded as span errors in OpenTelemetry traces.