Better Auth

BA

Better Auth

Join the community to ask questions about Better Auth and get answers from other members.

Join

bug-reports

help

Spotify redirect url

Now Spotify does not allow to redirect to localhost, testing Spotify auth is not possible

Reference naming doesn't fit all use-cases

As title says, I'm extending organizations plugin and I'm referencing organizationId ```ts schema: { branch: { fields: {...
No description

Stripe: `onSubscriptionUpdate` passes old subscription data

When the onSubscriptionUpdate callback is fired, it passes the subscription data grabbed from the DB. However, this is the data before the updated properties are applied. For example, if a user switches from one plan to another, the passed subscription object contains the old plan, not the new one. Relevant code:...

Generic oauth failing on missing email

Ouath providers that do not offer an email claim fail when using the generic oauth plugin with email_is_missing. Seeing how both Twitter and Tiktok allow for null emails, I would expect similar behavior in the generic oauth plugin as well. Or, alternatively, a way (a la Auth.js) to write and use custom providers. Moreover, mapProfileToUser has no affect on the above as this method is being invoked after the email check fails. One must use a custom getUserInfo method to get around this restriction. See here: https://github.com/better-auth/better-auth/blob/6a0898fa88d1a49163b711fdbfa05489e0301a2c/packages/better-auth/src/plugins/generic-oauth/index.ts#L606...

authClient.signIn.email returns status 0 with empty statusText — No descriptive error

I'm trying to implement email/password sign-in using authClient.signIn.email inside a React Native (Expo) project, but I’m getting a bland, unhelpful error message: ```bash Copy Edit...

Stripe plugin: seems we can't reactivate a canceled subscription

Hello, The title is self-explanatory, once a subscription is canceled, it seems there's no way to return to the portal to reactivate it before it truly gets canceled. Steps to reproduce:...

webcrypto issue w/ vite6(vs. 5) rr v7 ssr while in cf-wrangler [minflare]

Its not a bug i can point to yet because the likelihood is that its almost certainly vite or the vite config's fault but the following combination and using vite 6 vs vite 5 causes webcrypto not resolving. this causes subtle bugs in better-auth that i didn't pick up on and i thought were related to linked generic oauth issues. ssr step reports this: node_modules/@noble/ciphers/esm/cryptoNode.js (6:77): "webcrypto" is not exported by "vite-browser-external", imported by "node_modules/@noble/ciphers/esm/cryptoNode.js". node_modules/@noble/hashes/esm/cryptoNode.js (11:9): "webcrypto" is not exported by "vite-browser-external", imported by "node_modules/@noble/hashes/esm/cryptoNode.js"....

Admin plugin : listUsers total is not correct

Hi, When using list users the total returned do not take into account the filter clause. sample: ` auth.api.listUsers({...

BetterAuthError [BetterAuthError: Session data is too large

Get the following error when using cookie cache with Microsoft OAuth.
BetterAuthError [BetterAuthError: Session data is too large to store in the cookie. Please disable session cookie caching or reduce the size of the session data] Not an issue for users who log in without an image on their Microsoft account. it would seem that the image which is base64 encoded causes the session data which includes sesssion and user to be over 4093...
No description

Stripe Webhook Fails When Processing User Subscription

The webhook fails due to invalid values for periodStart and periodEnd.
2025-04-02T23:00:28.177Z ERROR [Better Auth]: Stripe webhook failed. Error: Invalid db[getModelName(model)].update() invocation in C:\Users\ayrto\tibiaprofit.next\server\chunks\node_modules_better-auth_diste7fe42cb..js:3150:62...
Solution:
I believe it's due to this breaking change. @ayrtonaguiar Do you think you can downgrade your stripe version to @17.7.0 until this is fixed?...

getSessionCookie does not work in middleware

I was trying to use getSessionCookie just now with my middleware and i kept getting null. ```ts const handleAuth = async (request: NextRequest) => { // log all cookies...

Issue: Session not retrieved on latest safari version

Description I'm encountering a session-related issue On modern browsers, specifically the latest version of Safari. While session retrieval works fine on Chrome, it fails on Safari. Context Backend: Running on Hono (Cloudflare Workers)...
Solution:
fixed with : ``` advanced: { defaultCookieAttributes: {...

Custom Plugin is not type safe.

I added the cart plugin as a client to my better auth instance, but when I try to access apiClient.cart.someMethod my IDE thinks it doesn't exist, but the method works on dev/prod instance. how can I let the IDE auto complete these types?
No description

Additional Date field throws an error

I added an additional field in auth.ts and also I infer the additional fields (as type date not required and default null) when I create the client inferAdditionalFields<typeof auth>(). The autocomplete works for that field and everything is great, but when I want to update that field using the authClient.updateUser({customDateField: new Date()}) the server throws and error: @repo/api-app:dev: # SERVER_ERROR: TypeError: value.toISOString is not a function...

Can't generate migrations using D1 on Cloudflare Workers

There is no way to run migrations while using D1 with Kysely on Cloudflare for 2 reasons: - The DB is exposed only at runtime, aka we cannot use the better-auth CLI to detect the configuration since it's only looking for variables exported (when using D1 we construct the configuration with each request and we only have a function) - The usage of getMigrations is still undocumented and probably abandoned since It's returning generic errors from D1 such as Error: D1_ERROR: not authorized: SQLITE_AUTH ```typescript...

getSession intermittently fails cookie signature verification, deletes cookies

We've been seeing erratic unexpected log-outs in our app, and have traced it down to the session cookie being deleted because it has the wrong signature here: https://github.com/better-auth/better-auth/blob/v1.2.5/packages/better-auth/src/api/routes/session.ts#L118 I have confirmed it is a signature mismatch by patching debug logs into getSession() — they show sessionDataPayload.signature doesn't match a signature created with createHMAC(...).sign() using the same contents....

Not able to create polar Checkout

Hi, I'm trying to create a polar checkout with polarCheckoutWithSlug ``` await auth.api.polarCheckoutWithSlug({ params: { slug: "premium",...

using authClient.organization.setActive() corrupts session_token in cookie

When ever I attempt to call setActive on the client:
await client.organization.setActive({ organizationId })
await client.organization.setActive({ organizationId })
...