Better Auth

BA

Better Auth

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

Join

bug-reports

help

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

Oauth in GoogleAddon

We are using better auth for a web app and a google addon so in web app we can use cookie based oauth login but in addon we can't, so we were trying to use bearer plugin but we are not able to get the 'set-auth-token' on onSuccess handler, i have tried onResponse handler also. Also i don't know if bearer plugin is good fit for the google addon because it also sets the cookie. What can we do in this case?...
Solution:
so when you use social logins we can't set cookies cause it returns back to your back with redirect headers. What you should do is issue send the token as a part of redirect url ```ts export const auth = betterAuth({ hooks: { after: createAuthMiddleware(async(ctx)=>{...

Update email of existing user entry that was created initially by verifyPhoneNumber API

I have an existing session already and I want that after I verify the email via magicLinkVerify API, the email of that user is updated rather than a new user being created altogether. Is that possible? I was only able to "merge" users when I first created a user with magicLinkVerify API AND THEN verifyPhoneNumber API to which the same existing user is updated (see second screenshot)...
No description

App infinitely reloading and not sure why.

In my Astro app i am using a simple middleware following the example in the docs and for some reason when i am on my root page it infinitely reloads the page, the issue seems to be happening when calling:
const isAuthed = await auth.api.getSession({
headers: context.request.headers,
});
const isAuthed = await auth.api.getSession({
headers: context.request.headers,
});
...
Solution:
I am was able to figure this out, when we try and auth a request we send it to /api/auth/* to get the session however the middleware will run on this meaning we will end up in an infinite loop due to it calling itself over and over again, not a problem on certain pages but possibly on others. my reworked middleware.ts ```ts import { auth } from "@/lib/server/auth"; import { defineMiddleware } from "astro:middleware"; ...

Client-side user impersonation in Better-Auth with OpenAPI-TS: Why does it fail?

Hi everyone, I need a hand implementing a method for updating a user's data from another user with elevated permissions. I could get my hands a little dirty creating my own endpoint or service to do this, but I think the tool will have a better way to do it. I'm currently creating a basic dashboard to get an idea of ​​how to use the tool built with React Router 7 (REMIX.js)....