Better Auth

BA

Better Auth

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

Join

bug-reports

help

Wildcard domain

I have an unusual use case for auth: my authentication database is shared between multiple apps running on different subdomains. Accounts created in one app also exist in other apps. This almost works. However, I’ve stumbled upon a weird problem: sometimes both Google and Email/Password authentication fail. Google reports an incorrect redirect_uri, while Email/Password reports an invalid origin. ...

Social login for native apps

Hey everyone looking for some guidance for native apps and social signin. My app is built using capacitor. On my signin page I capture the redirect by running the following ``` const { data } = await authClient.signIn.social({ provider, callbackURL,...

Session Caching with Custom Fields Workaround

I've been using Next Auth and was thinking to switch over, however the line below is making me hesitate. I do not want to hit the db on every request, but I also want to use custom fields such as roles. Is there an alternative or work around for this?
Session caching, including secondary storage or cookie cache, does not include custom fields. Each time the session is fetched, your custom session function will be called.
Session caching, including secondary storage or cookie cache, does not include custom fields. Each time the session is fetched, your custom session function will be called.
...

auth.api.getSession doesn't reading Authorization header

Im using expo and nextjs monorepo setup, and expo successfully sending Bearer token in Authorization, and nextjs receives. But when i pass the headers to auth.api.getSession, it can't find session. I'm using 3 plugins: oAuthProxy(), expo(), nextCookies()
Solution:
Have you checked if the headers contain the cookies required?

Modify User

I have ping id (GenericOAuth) integration in my MERN app using better-auth library. I saved the user once login, but what if the user details are modified in the ping console. like: roles, or group.

How to log in from the server

Hello, I have a login page with a form and I'm trying to signIn the user on the server: ```js export const actions = {...

OAuth custom headers in token request

Hi! I'm trying to integrate Vipps authentication using the genericOAuth plugin. Vipps requires specific headers (like Merchant-Serial-Number, Ocp-Apim-Subscription-Key) to be sent with the token exchange request (when getting the access token). I see the discoveryHeaders option, which is helpful, but I can't find a way to add headers specifically to the token request itself within the genericOAuth configuration....

nextjs + nestjs

i have a nextjs app with better auth setup. what would be the best way to handle auth verifcation on the side of the nestjs backend ?...
Solution:
Hey, there is https://github.com/better-auth/better-auth/pull/1548 coming, but there is also comment from user juandl , where he explains how he implemented it.

https://www.better-auth.com/docs/plugins/passkey

Adding the plugin and then running npx @better-auth/cli migrate generates nothing.
Solution:
run npx @better-auth/cli generate and update your schema manually. Migrate: This command creates the required tables directly in the database. (Available only for the built-in Kysely adapter)...

How can I do multiple Database calls 'during' user creation transaction in google OAuth?

Is there a way to write/hook into the User creation code when signing up with google ? I know that I can use the databaseHooks 'before' and 'after', but I want to do something 'during' the User DB creation that does multiple database inserts on signUp, because I want to use transactions to make sure they either all succeed or all fail, like this: ```javascript const onSignUp = async() => {...

How to handle this error myself?

I want to make it just include an error message in my form. Can I send it to a callback URL?
No description

Is it okay for getsession req to be made for every protected route or I should cache it?

Hey guys I have some routes which needs to be protected so I use this wrapper ```tsx export const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ children }) => { const { data, isPending, error } = authClient.useSession();...

JSON.parse error in Express.js

Hey, @Ping How are you man? How can find this error comes from and fix it?...
No description

Google auth on plasmo browser extension

Is it possible to use plasmo and have google auth with a plasmo framework extension? I see that the example uses password and username, but I’d like to add google auth. What would be those steps? I have a full Nextjs website with the Google auth setup already...

create user with signUpEmail

I'm trying to create an user on the server with auth.api.signUpEmail I can get the response object, but the user is not inserted in the database: ```js...

ERROR [Better Auth]: [#better-auth]: Couldn't read your auth config. Error: Neither apiKey nor

ERROR [Better Auth]: [#better-auth]: Couldn't read your auth config. Error: Neither apiKey nor config.authenticator provided Error occured when trying to generate schema after adding Stripe - npx @better-auth/cli generate...

ERROR [Better Auth]: Error Error: NOT_FOUND

Hello I have a problème with better auth in my express js backend : Error : ``` Body: { provider: 'github', callbackURL: '/admin' } [run] 2025-04-22T13:53:42.222Z ERROR [Better Auth]: Error Error: NOT_FOUND [run] at processRequest (file:///C:/Users/malev/OneDrive%20-%20Questindustries/Documents/GitHub/Project-Omega/Server/node_modules/better-call/dist/index.js:4833:25)...

"Email is missing" error with Generic OAuth2 plugin

I'm getting an error that the "Email is missing" when I sign-up using my generic oauth2 provider as the user endpoint returns only { accountId: string, displayName: string }. Clerk handles this by presenting the user with another form in which they must enter their email, but I'm not seeing how to configure this with better-auth. Anyone have ideas?...

Get google oauth access token and implement google refresh token

Hey everyone! 👋 I'm working on implementing authentication in my Next.js app using BetterAuth with Google OAuth, and I could use some help with two things: How can I retrieve the user's access_token after login?...