Better Auth

BA

Better Auth

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

Join

bug-reports

help

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

server actions for users

I want to understand how I would setup a user.actions.ts file with better-auth. Could anyone please help me out understand?

Argument `stripeCustomerId` is missing.

I'm getting the following error: `` 2025-04-18T03:02:49.602Z ERROR [Better Auth]: PrismaClientValidationError: Invalid prisma.user.create()` invocation:...
Solution:
BA probably creates the stripe customer after the user is created in the database not before

Get user info

I'm using the admin plugin and I can list all the users in the DB using await authClient.admin.listUsers() but how can I get a single user info? I can't find a method like await authClient.admin.getUser(id).
Solution:
If you have the user id, you can directly query your DB using something like an ORM.

user admin type not updating

i added the admin plugin which adds the role column to users. how do i update the type so it doesnt give me errors?
Solution:
i just checed and realized i put the plugins in the wrong place mb
No description

Prisma + better-auth: schema type issue

I have been struggling with this issue for the last 3 hours. Keep looking into the why I am getting an error on type after running the generate command and making a push to my local PostgreSQL database. I have setup a simple form using ShadCN (they also use react-hook-form under the hood) and some other components such as the input field. Could anyone please help me out?...
No description

Better auth handler not working

Hey, I'm currently experiencing another problem with my better-auth instance combine with Hono. The better-auth handler is returning a 404 for the get-session url and I'm not sure why. The route is clearly hit as indicated by the logging but the internal handler returns a 404 for some reason
No description

How to acces ID token returned by oAuth provider

I'm using the Microsoft oAuth provider. It returns an ID token, which (when decoded) includes some user information I need to access, such as user group memberships. The ID token gets stored in the 'accounts' table, but I can't work out how to access it. I can't see any way using auth.api. I know I could query the database independently, but it seems like I shouldn't have to do that to access something that better-auth is storing....

Better-Auth with Express Server

I set up basic Better-Auth in an Express server with sqlite database. Followings the docs I have auth.js ``` import { betterAuth } from "better-auth"; import Database from "better-sqlite3";...

Property 'signIn' does not exist

```typescript import { createAuthClient } from "better-auth/react"; export const { signOut, useSession, signIn } = createAuthClient({ baseURL: process.env.BETTER_AUTH_URL!,...
Solution:
first make sure to config your auth correctly and to do the recomend of destructing the object since i dont exactly know your rules config for that but i recomend this way and also the safest way ```ts const authClient = createAuthClient({ baseURL: process.env.BETTER_AUTH_URL!, });...

set a default redirect URL

im hosting my auth layer on a cf worker, and my nextjs on another worker. is there a way to set the redirect to always be on the nextjs worker? i dont wanna do callbackURL: "http://my.nextjs.app/" for all my calls...

Components not visible (BetterAuthUI)

Only AuthCard and AuthUiProvider is visible on the website. If you see user-button is a component but its not visible in the sidebar. Is it a UI bug? @daveycodez what am I missing? please check
No description

How to use better-auth CLI in a Cloudflare workers + Cloudflare D1 + react-router + drizzle project?

I created a React Router 7 project using the Cloudflare workers template: pnpm create cloudflare@latest my-react-router-app --framework=react-router . I added D1 bindings and drizzle to this project. The Problem: I am struggling to find a pattern where I can somehow export auth in a way the CLI can pick up....
Solution:
I recommend making a fake auth file and a real auth file. The fake one is just your better-auth config except for any fields which require ENV vars. This file will be the one you would then use for the better-auth cli to read. The real one would be the one which includes all needed ENV variables for Better Auth to function....

sign in stuck loading in deployed app

Hi there, I have an issue I am encountering in my deployed app but not local app. When I try to sign-in the user gets successfully authenticated but the loading button is stuck loading. This issue does not happen locally (of course 😂 ) and I am not too sure why that's happening. I know the request response shows redirect = false but the same is shown locally and the user gets redirected to their profile....