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 link multiple oauth accounts from the same provider ?

For my app, I need to allow users to connect apps to their accounts through oauth and they should be able to connect multiple accounts from the same provider (ex. google), is it possible to do in better auth?

Not able to infer fields from extended core User schema

auth.ts: ```export const auth = betterAuth({ database: pgPool, user: { additionalFields: {...

additional fields on Social Providers

How can we pass additional fields, or additional context to the social providers sign up the same way we do on email and password sign up?

Session empty on Elysia server but works on Nextjs client

I have a Elysia server running on port 3002 and my Next.js client running on port 3001. When I signup I'm able to hit the server fine and create a session which is saved to a cookie, but whenever I try and make a request to the server the session is null. I have a guard on each route I want to check the session. I included credentials: "include" on my client request as well ``` export const AuthMacro = new Elysia({ name: "auth" }) .mount("/auth", auth.handler)...

Example with express

Do you have any example with express and protected routes in express? Could not find any example in docs...

any confirmation api available?

I'd like to use passkey auth with logged in users as a way to confirm certain destructive actions. Example: "Are you sure you want to delete your account?" After clicking "Yes", you need passkey auth to confirm. Do you have support for re-auth? especially in the context of confirmations?

Create Session Manually

Hi. I want to manually create a session when a user is authenticated using social provider, i am not using better auth on the client side and everthing on my backend. Is that possible?

Basic authentication emailandpassword, refresh accessToken using refreshToken

I am using basic authentication, emailAndPassword, adn plugin jwt and OIDC provider. I want to refresh accessToken using refreshToken till refreshToken is valid

Dynamic RememberMe outside of email + password?

What is the best way to implement this? Right now it seems it can only be set in either the auth config or the authClient.signIn method?

Best Practice for Reusing BetterAuth Session in Next.js App Router

I'm using BetterAuth in a Next.js app (app router). I'm calling getSession() in different parts of the app—like a layout and a page—and it's causing the session to be fetched multiple times per request. What's the best way to call getSession() only once per request and reuse the result across server components?...

does better auth support refresh token rotation

looking for move form NextAuth to BetterAuth and looking for refresh token rotation support and the ability to configure multi tenant for oauth. Does better auth support this?

Do the default database adapters support transactions?

I'm experimenting with Better-Auth, but I noticed that the sign up flow inserts in multiple tables but it's not nested into a transaction. Checking the code for the default DB adapters, looks like non of them use transactions. Am I missing something? That looks like a huge deal
Solution:
not yet

How to force a user logout or delete a user based on login info?

So, this is my current setup for Discord based OAuth: ```ts export const auth = betterAuth({ ...
socialProviders: {...

Expo Sign in with google

Hello everyone, I recently encountered a problem using Better Auth with Expo. What happens: I log in normally to the application (social login with Google), but when I log out and log back in and try to log in with Google again, it seems like it doesn't set the cookies. However, if I reload the app, I log in directly and the cookies are there. Note: I'm using auth through an API in hono.js.

better auth error 404

no matter what we do in api/auth/sign-up and api/auth/login it is giving us better auth error 404...

Redis as secondaryStorage generate a lot of client connection to my redis server

Hello, i have setup my redis client inside auth.ts to use it as a secondaryStorage, i have added inside my code a small redis.on("connect",... to log when a redis client is created, and i have see that at each new page who use auth there is a dedicated redis client. (I have 6 pages, in my redis i can see 8 connection (next -> 6, me -> 1, backend -> 1) Does i have this because i have a wrong better auth setup or something like that ? My code :...

Proxy Database Queries

I have a Next.js application using Better Auth, deployed on Vercel. My Better Auth instance is configured to use an Azure MS SQL database. When mounting the handler (cf. https://www.better-auth.com/docs/installation#mount-handler), it creates route handlers (endpoints) that are hosted via Vercel Functions. These functions have dynamic IP addresses (unless you upgrade to Vercel’s Enterprise plan and use Secure Compute), which creates an issue because the MS SQL database requires IP whitelisting for its firewall. So how can we proxy database queries through a dedicated API with a static IP address that can be whitelisted in Azure? Or is there another solution?...

Trusted Origins Wildcards

Hello, I'm running into following error and I'm clueless if it's perhaps a BetterAuth Bug. I'm setting up my previews on Vercel and added following trustedOrigins into my list: https://*-my-team-gmbh.vercel.app but it's not working as expected. ...