Better Auth

BA

Better Auth

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

Join

bug-reports

help

React Router V7 + Better Auth (Plugin OpenAPI)

Hi! I have some question about plugin openAPI. Now I make a game with cocos creator use Typescript and I use React Router V7 for API and web admin page. And I try to fetch get session in my game but i show error "blocked by CORS policy" so now I have no idea what to do next. (I already add "credentials: 'include'" in fetch) (and I also try to create middleware to add CORS headers but it didn't work)...
No description

TansTack Start Integration

I have successfully refactored the better-auth nextjs demo to tanstack start https://github.com/better-auth/better-auth/tree/canary/demo/nextjs But I have a question: ...

Generate random id

when I insert an user, a random id is generated, is it possible to use that api alone or configure the number of digits or composition of that id?

additional fields

organization({ schema: { invitation: { additionalFields: { metadata: {...

User Name on Social Providers (Apple, Google, etc)

When signing up/in with a Social Provider, is there any way to apply the user's name to their name? Right now with Google their name is set as their email address, and seems the same as well with Apple. I'd like to have their name if possible on their profile, or possibly leave it as null instead of as the email....

Cookie not persisting on client

I am testing better-auth with a frontend on http://localhost:5173 and a backend on hono + aws lambda. The request works but the cookie is not being persisted in the browser. On the client I have a pretty standard configuration ```...

how to use it with nuxt 4 and reverse proxy

I build my nuxt 4 project with better-auth and run build result behind nginx proxy manager plus When in dev everything is okay But in prod I can't login anymore. cookies set in my browser but server didn't think so...

SSR Not Working On Cloudflare

I am using Nuxt in my project and have copied the Better Auth setup from nuxthub-better-auth repo that seems to be working fine in their example. Everything is working fine, the SSR is working fine for everything BUT user/session data. as you can see here https://sutando-client-example.dventures.workers.dev/ as compared to the example https://better-auth.nuxt.dev/user You can see in the __NUXT_DATA__ that the user list api data is there during SSR, but not the user & session data from BetterAuth....
Solution:
Solved kinda .... NuxtHub uses Pages - the SSR for the BetterAuth only seems to work on Pages and not Workers

How to remove '__Secure' prefix from the cookie name?

This might sound like a stupid question but, is there a way to remove the '__Secure' prefix from the name of the cookie without having to disable the secure property of the cookie in production mode?

How to get autoSignInAfterVerification to work ?

Hello there ! 👋 As you can see on the screenshots, I tried adding autoSignInAfterVerification + emailVerificationRequired, but it seems like it just does nothing when I click the url in the mail, I am redirected to my frontend url but I am not logged in, any idea why ?...
No description

Accessing additional values from session data

Hello, I've tried to access additional fields on my user object, but it seems both serverAuth.api.getSession({ headers }) and clientAuth.useSession() doesn't return the additional fields. Is there a way to accessing both snowflakes and cover_image from session? Here are my code Server Config...

How to use better auth instance defined in different server in nextjs api route

Better auth is initiated in my api server and I would like to use it server side in a nextjs api route. Is there any neat way to call better auth in the api server? The Nextjs deployment in vercel doesn't have access to the db directly.

activeOrganizationId is null

Hi, i've been running into an issue that i've been trying to debug for a couple days now. With the org plugin, activeOrganizationId on the session is (usually) null, causing getActiveMember to break too. Adding the below to my auth config sometimes fixes it, but sometimes it inexplicably breaks (for some orgs specifically). ```ts session: {...

Better-Auth with Tanstack Start + Tanstack Query

I have successfully refactored the better-auth nextjs demo to tanstack start https://github.com/better-auth/better-auth/tree/canary/demo/nextjs But I have a question: ...

setup middleware on backend with oidc

I have three services: 1. expo app (client) 2. hono + better auth (oidc provider) 3. hono app (server) ...

Custom session plugin in monorepo

I have a monorepo with 2 projects client and server. Both have their own package.json and tsconfijg.json. On the server I have configured better-auth to provide a custom session: ```ts export const auth = betterAuth({ /* ... */ plugins: [...

Is there a way to create an "always valid" OTP for testing?

I am currently migrating from clerk to better-auth and I am wondering if there is a way to create OTPs that are always valid

How to implement single device login or single active session at a time with better-auth

i want to implement single device login where user can have only one session active at a time if user try to login his account into other device then logout from other device
Solution:
```session: { create: { before: async (session) => { await db.session.deleteMany({ where: {...

Should API Key plugin hook removeUser?

Using the apikey plugin, if I try to remove a user with the removeUser endpoint, it fails if the user has an active API key (foreign key constraint failed). Is that expected? Do I need to manually delete the API key myself in a hook or something else first?