Better Auth

BA

Better Auth

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

Join

bug-reports

help

Microsoft Provider

I'm having trouble getting Microsoft authentication to work. I keep running into this error: ERROR [Better Auth]: State Mismatch. Verification not found { state: '' } On signIn.social({ : 'microsoft', : '/' }) and linkSocial({ provider: 'microsoft' }); ...

two factor with social

Hey I see in the documentation that enabling two factor requires a password ```ts const { data } = await authClient.twoFactor.enable({ password: "password", // user password required...

Stripe Plugin webhook error

Getting this error in better auth stripe webhook : 2025-04-16T20:24:59.891Z ERROR [Better Auth]: Stripe webhook failed. Error: Invalid time value POST /api/auth/stripe/webhook 200 in 175ms POST /api/auth/stripe/webhook 200 in 14ms...
Solution:
use stripe sdk version v17.7.0, anything above is not supported yet

No mention of callback url in docs for Apple

I am adding social sign in and already added entra and google. However with apple, it works and i am getting the prompt to sign in with them however after that is done i get error
{"code":"INVALID_ORIGIN","message":"Invalid origin"}
{"code":"INVALID_ORIGIN","message":"Invalid origin"}
There was no redirect url explanation in the docs so i assumed it would be
https://domain/api/auth/callback/apple
https://domain/api/auth/callback/apple
and added it to the redirect urls in apple's service...

Better Auth + Tauri + Sveltekit

I have successfully implemented better auth into a sveltekit + tauri app, but once logged if i refresh the session is lost and it is null on the hooks.server.ts (where i do auth guards too). Has anyone succesfully used better auth in tauri?

How to extend Sing-in & Sign-up body with custom fields?

Is there a way to pass a custom field though client.signup.email / social ? ```ts await signUp.email({ email: values.email,...
Solution:
Yes you add additional fields to user in the auth config

Drizzle + PG + Hyperdrive + Cloudflare Workers doesn't work

I've spent all the day to solve issues. At the end I left! I built a custom plugin and I ended up that cf close my db connection and the plugin doesn't work 😦 Switching back to vercel...

Unprocessable Entity on Signup

Hey, just ecountered an Error I haven't seen. This happens when trying to signup via the authClient. This is my code: ```ts const { data, error } = await auth.signUp.email({ email: formData.email,...
No description

How to set CallbackURL in emailVerification

I'm using BetterAuth for email verification in my app, and I need help setting the callbackURL for the emailVerification process. In my auth.ts file, I'm trying to send a verification email, but I can't figure out how to properly set the callbackURL that the user will be redirected to after clicking the confirmation link. How do I configure the callbackURL in the emailVerification setup in BetterAuth?...

Invitation email

I probably missed something but in the doc, I don't understand how the invitation email is actually sent. We can read this: ```ts await authClient.organization.inviteMember({ email: "test@email.com",...

build error -next js

Creating an optimized production build ... Failed to compile. ./node_modules/better-auth/dist/client/react/index.mjs Attempted import error: 'useRef' is not exported from 'react' (imported as 'React')....

Using custom schema for models, with prisma adapter.

Can you specify different database schema when using postgresql with prisma? For example, I have my user table in auth.users rather than the default public....

Installation problems

Hi, I'm trying to discover better-auth, so I start installing elysia, prisma and then better-auth, except that by following the doc, the "installation" part, from start to finish, I still can't understand how it works, the route localhost:3000/api/auth doesn't work and tells me NOT_FOUND
Solution:
I think it's normal that /api/auth is not found.. 😅 There is nothing there to do after all...

Stripe Better-Auth Plugin

I have an issue with the Stripe plugin (or maybe Stripe itself). Im implementing subscriptions and I'm getting conflicting events after a checkout in the Sandbox. First I get a OnSubscriptionComplete, I use the status to update the user's proStatus to "active"....

Throwing Error when try to login with existing user

`export const auth = betterAuth({ database: drizzleAdapter(drizzleDb, { provider: "sqlite", }), socialProviders: {...
Solution:
i think adding a small note in the migration guide might be useful
No description

Drizzle Postgres UUID

How can I force better-auth to use uuid's for id's and rely on the database to generate them with the drizzle adapter. The below doesn't seem to work. ``` advanced: { database: {...

Verification model not found in schema object

I thought that this error came from because it couldnt find the location of the auth schema but even after i put passed it into the config im getting the same error.
Solution:
figured it out, schema object had to be inside the adapter config not the betterAuth config 💔
No description

When impersonating a user, is it possible to set that session as the current session?

useSession after enabling impersonation still returns the original admin user, but as we use that for the whole dashboard, I'm wondering if we can make useSession return what we need here

disable magic link redirect and any other redirect

Hello, I am using better-auth with a Fastify backend, a classic REST api (port 4000) and for the frontend I am using next.js 14 (port 3000). So I managed to configure better-auth on the backend through a custom Fastify plugin. For the signin I am using the magic link plugin....

Session info isn't available fast enough on manual page reload, server sign in api needs reload

For any brave soul willing help me with this problem I posted to better-auths github I've included the info from that issue below Using SolidStart and Postgresql better-auth version: 1.2.7 OS: Microsoft Windows 11 HOME version: 10.0.26100 Build 26100...