Better Auth

BA

Better Auth

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

Join

bug-reports

help

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

redirect_uri starts with http

I have an application served using https. But better auth gives the redirect_uri in http

Migration Guide from Clerk to Better Auth

Hi, is there a migration guide from clerk auth to better auth?

Anyway to access admin API from server?

I seem to be getting a 401 error on calling my auth API endpoints from my server await auth.api.listUsers({ query: { limit: 10,...

API Organisation Types

Hi, In the documentation, it only mentions using the authClient to interact with organizations, but I have a need to manage them from the backend. So I tried to see if something like auth.api.organization existed, but couldn't find any trace of it. Could you point me in the right direction?...

global onSuccess question

Hi guys, first of all - thanks for the great library! I'm just following the documentation, and maybe missing something here: ```export const { signIn, useSession, token} = createAuthClient({...
Solution:
yeah global on sucess has some issues caues there is another one applied by the library by default. Will be fixed soon but use onResponse instead for the time being

Super Admin role creation assistance

Hello Team, I am looking into creating a role based access control system within my app, I would like to have SUPERADMIN, ADMIN, USER level roles and wanted to see how i can add a new role and make use of this system. auth-client.ts...

User as an organization

I would like to do the sign up, whenever someone sign-up to the app, i create an organization for that user, and the user can invite employees, but i would like to assign the subscription for the organization, not the user. So basically the flow is, on sign-up, i take the organization data, and some of the user data, and create an organization and add the user to that organization. Is it possible now with better auth, or only the user can have a subscription? ...

Cookies amongst multiple tenants, subdomains, and custom domains for a SaaS

Hey folks, I'm working on what is ultimately Squarespace for a niche, where users will get a unique subdomain, and can also add their own custom domain (so we have mycoolapp.com where i'll be serving the marketing, john.mycoolapp.com, and maryscoolapp.com). Looking for guidance on how to get it working with BetterAuth; my stack is SvelteKit, with Postgres + Drizzle (using the direct Postgres connector, though), with Directus as the CMS for end users. Currently I'm having an issue where the cookies are being set on the TLD and not working on the subdomains. I'm aware that there's an organisation plugin, but that doesn't look to have anything specific to sharing cookies between sites....

How do you let the user choose which Google account to use when using social sign-in?

Currently, when I click "Sign in with Google" it just logs in to the last account I used. Is there a way to have me choose which account to use via a pop-up window?

How do I implement authentication for tenant's clients with better-auth ?

I have an b2b2c app based on vercel's platform starter with an basic auth implementation for tenants..however I am not sure how should I implement auth for tenants clients...any guide or resources would be reaally helpful .. I am sharing the example repo below ... https://github.com/ra-kesh/stayin-platform...