Better Auth

BA

Better Auth

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

Join

bug-reports

help

deleteUser response: FAILED_TO_GET_USER_INFO

Hi, I'm using deleteUser() with sendDeleteAccountVerification. E-mail is sent with correct token. But whatever I try, the response from my Express API is FAILED_TO_GET_USER_INFO. I'm on version 1.2.7 in both client and server...

Updating email_verified and image fields

Hi, My app supports credentials & Google OAuth login. I verify emails when users sign up using the credentials method. After using the credentials method to sign up, before verifying their email, if the same user (with the same email) signs in with Google, the user table doesn't update the email_verified to true (if Google passes this email, we can safely set the email_verified field) and image field also is left empty....

Unclear how to call phoneNumber signup from frontend

I'm using phone-number for sign-up, my authClient looks like .. ``` export const authClient = createAuthClient({ baseURL: "http://localhost:8081",...
Solution:
You have to send the otp for the verification and make sure to pass signUpOnVerification to set up a temporary email since right better auth requires an email fields and also the same for name. And you can sign in back with signin.phoneNumber .

cli generate not working: "Please run prisma generate"

Hi, I'm very new around better-auth and I need some help figuring out how to set it up properly. I have followed the instructions but for some reason I cannot seem to run the command npx @better-auth/cli generate. Gives me back an error that says "Please run "prisma generate" and try to import it again. However this has already been done and when I run the command it comes back to the same error.

I cant decode better auth session cookie.

Here is the snippet: https://pastecode.dev/s/dcdiax2w It's golang middleware, i am trying to decode my custom cookie with my secret. But the decoded user id is not correct, here is the log:...

How to set Bearer token in Next.js

Hello Everyone, ```jsx import { createAuthClient } from 'better-auth/react'; ...

How can I configure something like nextauth `callbacks.signIn`?

When user signin by apple or google oauth, I want to query user information from my exists database, and verify that the user, and return new user information to session in nextauth I can do something like: ```typescript...

Unclear on how to handle session and cookies in sveltekit

I've followed the sveltekit guide from better auth website However i think it is unclear on how to do sveltekit auth on server side, on the example you do so by doing it on the client but normally you would do a login +page.svelte and then a +page.server.svelte and there you would call the auth.api.signInSocial (or email). Example: ```ts // auth/login/+page.server.ts export const actions: Actions = {...

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: "[email protected]",...

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