Better Auth

BA

Better Auth

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

Join

bug-reports

help

Get enabled authentication methods

Is there any way to get an array of the available authentication methods from the auth client? That way I could create my login component to automatically show whicever ones are setup.

How to Get User after SignUp with Hooks when requireEmailVerification is true

For some reasons, since email verification is required after sign up, I couldnt get user context in the hook. With the After hook, I populated some modeled data to the database after sign up. But since email verification is required to get a session Im kind of stuck. All I need is the user.id after the signup. And this Id is sent as a response to the user after sign up. from the Middlewarecontext i am able to get a request body, Is it possible to get a response? Or is there a way to go around this to get a UserID after they signUp from middleware? Or Do I have to do something else?...

Account linking social -> credentials

Hi, Can you not link an credentials account to an already existing social provider and user? I already have an user and a connected account with say microsoft. The user tries to sign up with email+password as well but get an error that the email is already in use. It works fine the other way around....

Multiple domains

Greetings, I have been studying better-auth and really liked it, however, I would like to know if it would work with two different domains, for example auth.domain1.com -> domain2.com, working with both email/password and Google oauth for example, is this possible, if so what is the configuration? I saw that it accepts cross subdomain, but that does not suit me. Thank you.

Working with modified schemas

Hi, Let's say I want to use the admin plugin but modify it a bit, what's the best approach? I'm using the users table but also an admins table which shares the user PK (which acts as a FK as well). Is there a way to change how the admin plugin detects the role? Also, what's the recommended way to deal with these kinds of schema differences?...

Use existing User Database

Hey, I already have an existing Discord user database from my Discord. This database will continue to be populated and updated by my Discord bot backend. Now I want to create a Next.js app for the backend. I want to use BetterAuth there, but it should utilize the existing Discord user database. There’s no need for duplicate entries in the database. The app will only support Discord login. Are there ways for BetterAuth to work with this setup, or do I need to adjust my database schema?...

What's the difference between the session and the token?

Heyo, I've been trying to get better auth to work in a Nest environment. I noticed that a call to signInEmail returnes a token, but I can't use the token to authenticate subesequent; If I register better auth as a direct handler into express, the cookie has an additional suffix....

Multi domain Auth

We have a main NextJS app where better auth works like a charm, now we have another React micro frontend (can be hosted in multiple domains) which we want to communicate with the main app api with auth. Please anyone suggest the best approach to do so.

Session Expiration Limited to 1 Day Despite 7-Day Configuration

We're experiencing a session expiration issue with Better Auth where our sessions are only valid for 1 day instead of 7, despite the specified configuration. In our logs, we can see session creation with: ``` sessionExpiresAt: '2025-05-02 19:40:17.627',...
Solution:
I discovered that setting rememberMe: true resolved our session expiration issue. Sessions were only lasting 1 day instead of the configured 7 days. The current documentation only states:
"rememberMe: If false, the user will be signed out when the browser is closed. (optional) (default: true)"
...

cross subdomain cookies issue

this is part of my config: ```ts export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql",...

Single Redirect URL SSO

I'm building a multi-tenant application where each tenant brings their own SSO provider, so I have a lot of individual providers. I see that better-auth by default uses a separate redirect url for each sso provider, but this makes it more difficult to orchestrate. Is there any way around this?

How to configure custom ID column names (e.g., id_user, id_session) ?

Hello everyone, I'm trying to customize the ID column names in my database schema. By default, better-auth uses id for the user table, id for the session table, etc. I'd like to use id_user, id_session, etc., instead. I attempted to configure this in the auth.ts file like this :...

Why few keys dont have ttl in redis?

Hello i notificed few keys have no ttls that means that will remain forever But those are not not required forever right? some optimisation should be there :betterauth:...
No description

How handle RLS

Hello, I’m new to Better Auth and Drizzle, and I wanted to know if there is an equivalent to Supabase’s auth.id() function in Better Auth and/or Drizzle, or otherwise how to properly identify the logged-in user in order to apply the correct RLS. Thanks in advance.

cloudflare timeot

I used Better in my Hono Backend. And this is my auth file. import { betterAuth } from "better-auth"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; import * as schema from "../schema"; import { bearer } from "better-auth/plugins"; import { db } from "../../turso";...

Next.js 15 + BetterAuth + HonoJS TS issues for user, session

Hello amigos, I have strange issue.. So thats my simple API endpoint to get user profile: .get(...

making a custom id with advanced.database.useNumberId = true not working

I'm trying to create a custom int id for the user from 1 to 999999. But the problem it goes to the default and creates a user with autoIncremented id ```ts const auth = betterAuth({ database: prismaAdapter(db, {...

How to get organization plugin data into OIDC claims

I successfully set up the organization plugin, good stuff. However, I'm unsure how to access this data and set it as user claims for OIDC ID tokens. OIDC plugin getAdditionalUserInfoClaim's first parameter is the user object, but the user's org info isn't listed on this object. Missing something?

how to auth.api.createOIDCProvider without user session

i want to create oauthApps at runtime. but calling createOIDCProvider requires a user session? ```js await auth.api.createOIDCProvider({ body: {...

Organization role customization

Goal: Have only custom roles and access control for organizations Observed Behavior: Things still being created as "owner", I think "admin", "owner" and other roles still exist. I only want my custom roles, and I want the creating user to get the custom role as well ("parent" in this case). Background: I'm building a family management app, using an organization as the "family", and I want to have custom roles for parents and children, etc. I have followed the custom roles/authorization docs for the organization to customize things. Here is what that looks like so far:...