Better Auth

BA

Better Auth

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

Join

bug-reports

help

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 })
...

auth.api.getActiveMember does not have type signature for role

When using the organization plugin with custom roles the role key in api.getActiveMember is typed as a string. This same key on the authClient is typed as expected....

The getFullOrganization() members.user type doesn't include id: string but the data does

Hey, I think the title says it all. When calling getFullOrganization(). I get an array with members. The user inside of the member does have an id key but typescript is mad when I make a type like the screenshot. When I add "id" to the omit, it's happy again....
No description

The field "teamId" does not exist in the "invitation" schema.

The public docs page needs an update to show this field in the schema for people not using the schema generation tool: https://www.better-auth.com/docs/plugins/organization

Stripe List Subscriptions with referenceId always throws 404

Hii, I just tried to implement the Stripe plugin on my website but unfortunately as soon as I try to fetch the active subscriptions using an organisation reference id it always throws a 404 error. I use SvelteKit, this is my implementation: ```js const { data: subscriptions } = await authClient.subscription.list({ referenceId: "TwaTAtP11GPvf3hrlumtNzkgJsBN8DPf",...
No description

[STRIPE] Annual discount & Upgrade

1. When updating a subscription and the user already has a subscription, the existing subscription is fetched incorrectly resulting to trying to create a new sub instead of updating existing one -> ISSUE https://github.com/better-auth/better-auth/issues/1880 -> FIX https://github.com/better-auth/better-auth/pull/1881 2. The getPlanByPriceId doesn't take into account the annual discounted price id...

Network error!

Sometimes, my users report encountering a sudden "Network error." The issue occurs unexpectedly, but when they sign in from another device, it works fine, and the error resolves on its own after some time. What could be the root cause of this issue, and how can I effectively fix it? CC @bekacru...

if verification.disableCleanup set true, then the records were getting deleted in verification table

I have set the verification.disableCleanup as true, still the records in verification table are getting deleted

NextJS build error

Hello, I'm trying to run the NextJS project build with better-auth but I'm getting the error. Could someone help me? ```Failed to compile. ./node_modules/better-auth/dist/client/react/index.mjs...
No description

Double Owner member ship creation on creation of organization

I have upgraded to v1.2 but am having issue where when you create an organization the member ship get created twice and i even inspected if am making double request but not yet and i don't have double middleware and this is the block of code am using creating organization ```ts await authClient.organization.create({ name: data.name,...
No description

TypeError: Cannot read properties of undefined (reading 'value') at withReturning

this is a fun error
TypeError: Cannot read properties of undefined (reading 'value')
at withReturning (/Users/omar/code/1up/node_modules/better-auth/dist/adapters/drizzle-adapter/index.cjs:169:38)
TypeError: Cannot read properties of undefined (reading 'value')
at withReturning (/Users/omar/code/1up/node_modules/better-auth/dist/adapters/drizzle-adapter/index.cjs:169:38)
...

Error: invalid column data type undefined - when running generate migration

Error running the cli generate. In addition to diagnosing, I think the error logging should be clearer here. What column? better-auth 1.2.4 ``` % npx @better-auth/cli@latest generate...

pnpx @better-auth/cli generate removing session table

I am doing something wrong, as the cli generate with drizzle adapter automatically removes the session table on each run?

Drizzle adapter usePlural not working with passkey & JWT plugins

I'm having an issue with usePlural for Drizzle where passkey is being entered as passkey but jwks is being entered as jwkss. For passkey, I got it to properly generate the correct plural but I had to add the following to plugins: ```ts passkey({...
Next