Better Auth

BA

Better Auth

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

Join

bug-reports

help

Unknown argument `stripeCustomerId` when creating customer on signup

Hey, I'm having a new issue where updating the user's stripeCustomerId automatically on signup, gives me a prisma error. I found an other thread here where the issue was the schema not having stripeCustomerId set as optional, but my schema does. Has anyone else had this issue?
Solution:
ok yea it was my fault. I got a warning from prisma to set an output path for the generated client Warning: You did not specify an output path for your generator in schema.prisma. This behavior is deprecated and will no longer be supported in Prisma 7.0.0., but then forgot to change the PrismaClient import statement from the old default path.

Handling better-auth.two_factor cookie after TOTP verification and logout

Hi there, I’m using Better-Auth with TOTP-based 2FA and had a question about the better-auth.two_factor cookie behavior. I’ve noticed that after a user successfully verifies their TOTP code, the better-auth.two_factor cookie remains present in the browser — even after a full session is created. Similarly, it doesn’t appear to be cleared when the user logs out. This leads to a UX issue where, after logout, my middleware sees the cookie still present (but no session), and incorrectly redirects users back to /verify-2fa instead of letting them hit /....

Expo plugin isn't a valid plugin

Just set up an external backend for my app and for some reason the expo plugin from import { expo } from "@better-auth/expo"; isnt compatible with the type BetterAuthPlugin. Error: ``` Type '{ id: "expo"; init: (ctx: AuthContext) => { options: { trustedOrigins: string[]; }; }; onRequest(request: Request, ctx: AuthContext): Promise<{ request: Request; } | undefined>; hooks: { ...; }; }' is not assignable to type 'BetterAuthPlugin'....

Trying to make my plugin work as npm package with bun

Hello everyone, I built a better-auth plugin. It works perfectly when I use it directly in my app. But it doesn't work when I try to put it as an npm package. I tried to bun link it with
bun link my-plugin
bun link my-plugin
and copied the way @better-auth/stripe handles it. But it still gives me this error: Module not found: Can't resolve 'my-plugin'...

something worong with cloudfalre

Hi everyone, I'm encountering an issue while deploying my Next.js project to Cloudflare Workers using OpenNext, and I'm also using better-auth for user authentication. I'm getting the following error: ```json...

Exploring Better Auth SSO Plugin – Guidance on authClient.sso.register Usage

I’ve created a sample repository to explore the usage of the Better Auth SSO plugin. While working on it, I was unsure about the appropriate placement and timing for calling authClient.sso.register, especially since invoking this API requires an active user session. Additionally, there is no implementation provided for signInWithTestUser, which added to the confusion. Documentation reference: Better Auth SSO Plugin - Register an OIDC Provider...
Solution:
so the sso plugin is meant to be used by allowing users to register a custom provider that can be used later to authenticate user

Multiple apps sharing the same database using Better Auth

Hello! You guys are doing some awesome stuff with this framework. I am wondering if it is possible to have the following setup:...

organization plugin for "embedded" use case (no user login)

Simple example to understand my question better. You have a restaurant and a few ipad minis. now each staff gets an ipad. instead of requiring the staff to create an account and be invited, id want that the admin can create a staff "with just name" and then generate like a magic link that logs you into a session with the correct permissions. Is this possible? any tips to get on the right track for this? Currently im assuming i just need to create an account for them with some fake email and random password they will never use...

How to manage 2FA Trusted Devices?

After marking a device as trusted in 2FA . How do you: * get all previously trusted devices and * Remove an older device from the trusted list...

how to use kysylo-adapter with better-auth

i want to write t3-app with kysylo and better-auth. but i found i can't use kysylo-adapter.

[OIDC] federated logout (`end_session_endpoint`)

Does BA implement the OIDC standard end_session_endpoint in the OIDC provider plugin for federated (RP-initiated) logout use cases? Section 2 "RP-Initiated Logout" in the spec here: https://openid.net/specs/openid-connect-rpinitiated-1_0.html...

Better Auth with Capacitor

Hi everyone, I’ve set up a backend using Hono and BetterAuth. My frontend is a ReactJS project with Capacitor. I’ve also installed BetterAuth on my frontend to use client functions for logging in and other things. Everything works fine when I use a regular browser, but when I build the app natively with Capacitor, the token isn’t stored. Do you have any tips or can you provide an example somewhere?

Multiple accounts with the same e-mail

I would like users be able to have multiple accounts with the same email but with different providers. Eg, 1 magic link account and 1 social (microsoft) account. They should not be linked together. Is this possible? I just get error account_not_linked when trying to log on with microsoft when a magic link account already exists...

Magic link verify on a secondary device

Is there a simple / built-in way to achieve where you can verify the log on attempt from a secondary device? Eg, if you want to log onto a tv where you cant receive emails. So you could just click the link on your phone instead and the tv would be the one logged on....

Account linking extra info

I have a question regarding account linking (using Google as the provider). Right now, I’m able to link an additional account with a different email address by using allowDifferentEmails: true. it seems like there’s no way to extend the account schema. I think it’s pretty common to have information like the name and email of a newly linked Google account, so that on the client side — when using authClient.listAccounts — I can display each account’s name, email, or other relevant info. I tried using the hooks and databaseHooks, but I couldn’t get it to work....

plugin schema: onDelete: "cascade" does not work?

Hi, I am creating my own plugin that creates groups within organizations. Part of my schema is this: ...

manage sessions in server

i want manage in server side in next js but docs not help? how can i manage sessions in servers

How to create headers on the server

Hey, our setup has a gateway in front and that one validated the jwt token I get back from the jwt plugin as passes forward the claims into a custom header. I now also want to provide some admin functionality but at the point where I am getting the request (via GraphQL), the session header is already gone and its unclear to me from the examples how I would f.e. call listOrganizations or listUsers on the server by passing in the user.id that I get back from the already validated token header. I could query the DB myself, but that kinda feels off...

what tables are a must for better auth to work

hello, i wonder to know why beter-auth uses so many tables and if they are optional i want to delete them specially session table which makes my db usage pretty high and costy. what do you say about this?

Is it a possible to use a relation table as type for fields in additionalFields ? (beginner 😅)

I'm currently working with better-auth and I’d like to access the pages field of the user directly from the session (code snippet below). (It's another table). Is it possible / a good idea to include this kind of data directly in the session (via customSession) or should I rather fetch it separately using a /me endpoint after login? I’m not an auth expert, so I’m not 100% sure what the best practice is here – any feedback or guidance would be super appreciated! 🙏...