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 to pass custom value to OAuth

I want to pass a custom value along with a server-side auth.api.signInSocial call for account creation, so that I can intercept that value once the user's account is created and couple it to the right user. What would be the best way to do it? I've noticed that custom body parameters don't work. Specifically I want to do this for Google oAuth and Microsoft OAuth. Thank you....

Nuxt's useFetch in Admin plugin?

Hello all! I'm tryiong to build a small "users" dashboard in my Nuxt app, essentially by building a UI around the Admin plugin. In the core Better Auth functions I could pass the useFetch function to make SSR work, I'm not seeing the same option in the Admin plugin however. ...
Solution:
With SSR you'd typically use the auth.api client

Better Auth with websockets

im trying to use better auth with websockets, where i get the user's session when they connect with api.getSession and use the bun websocket data to associate that with the connection (a new token is returned for the client to auth messages in that connection tho), is everything better auth needs to get a session from headers included in the initial request to open a websocket? cookies seem to be passed but i am getting a 401 on the initial request My frontend is astro, my backend is using Bun for the websocket and http api (was using express but the websocket stuff in bun is really nice and i am using mongoDB...

Cookies disappear on web app after refresh in production with Turborepo setup using better-auth

I have a Turborepo monorepo with two apps: apps/server — handles backend and authentication apps/web — frontend app consuming the auth API from the server...

Dynamic Callback URL

Hello there šŸ‘‹ . I was wondering if there was a reasonable way to dynamically change the callback URL? As of right now, we have preview environments that are loading up, and they essentially copy over all of the env vars from the dev environment (including the BETTER_AUTH_URL). I was hoping to be able to use a callback or config option somewhere to change this behavior to use the current domain rather than a hard-coded config value. Is something like that possible?...

better-auth expo client doesn't handle cancelation correctly

- Expo app with expo client plugin, Hono backend with expo server plugin - Start an OAuth flow in an external browser with let result = await authClient.signIn.social({ provider: 'google' }) - Cancel the OAuth flow - result is ...

The user data ID is empty in the before hook of the database.

Is this phenomenon normal in this hook? Because when checking the TypeScript type definitions, it is certain that there will be an id.

Authenticate Next.js app against Express backend.

Hi! I'm trying to setup Better-Auth API in my express app and have it linked to my next.js app, so I can make authenticated requests from client and server components. I got it somehow working but I have my Next.js app with a different url using nginx (local.dev.com), so that way I can test locally Riot Games OAuth. When I try to log in from localhost it works fine (I can get the session from both client and server components), but when I use the local.dev.com url it doesn't work on server components. Any help is appreciated. I honestly don't know if it is a good idea to setup authentication like this (a fullstack app with another backend)....

onboarding new users

@Better Auth I'm using social logins/sign ups (google and github) and passwordless otp for email signups in my next js app. if a user sign ups using google / github we can assume email is verified. And if new user successfully verifies otp token during sign in, we create session and redirect to onboarding route. how do i differentiate new users from old users during sign in. what is the auth configuration to achieve this?

Better auth in monorepo

Hey, quick question I’m starting a monorepo project with Next.js and Expo. Is it possible to have Better Auth in the packages folder and then export it for use in both Next.js and Expo?

First Timer - Understanding Client vs Server

Hi guys! I just met Better-Auth after a friend recommended it to me and I'm really excited to try it out! So far I tried using it with NextJS from a server only perspective (I'm also learning Nextjs), but I got a bit confused about the Client/Server boundaries. In the Basic Usage section of the Documentation, it starts with:...

Better-Auth With Different backend (FastAPI)

Hey guys, i want to use NextJS for its SSR but not use any of its server features. I will have a FastAPI backend as the main server. Can I use better-auth in this case? Im still unclear on where the server/client boundary is with all of this, new to nexjs in general. If I can use it this way, is it recommended? Thanks a lot!...

Convex? Ditching WorkoS

Hi All - My company finally agreed to ditch WorkOS for Better-Auth.
Has anyone had any good implementation happy dayz connecting to Convex? I will try this tomorrow and see how it goes. https://github.com/get-convex/better-auth...

Is there a way to access the `event` object from hooks in Nuxt / Nitro?

I have an application that sends an email to the user when they register in the databaseAfter hook. I am using @nuxtjs/i18n and need to use the event object for the language of the email. Is there a way to do this?

(on middleware) [Better Auth]: INTERNAL_SERVER_ERROR Error: Failed query

2025-08-10T13:39:59.581Z ERROR [Better Auth]: INTERNAL_SERVER_ERROR Error: Failed query: select "id", "expires_at", "token", "created_at", "updated_at", "ip_address", "user_agent", "user_id", "impersonated_by" from "session" where "session"."token" = $1
params: 7lIiWUkRjrVmOh4UJ0rZgjrvITaKu3ve
2025-08-10T13:39:59.581Z ERROR [Better Auth]: INTERNAL_SERVER_ERROR Error: Failed query: select "id", "expires_at", "token", "created_at", "updated_at", "ip_address", "user_agent", "user_id", "impersonated_by" from "session" where "session"."token" = $1
params: 7lIiWUkRjrVmOh4UJ0rZgjrvITaKu3ve
...

Have I been pwned?

When we use the have I been pwned plugin, on signin if we try to login with an account that doesnt exsist with a compromised password. It says change the password as its compromised, but in relaity the compromised check should only check on signup and login message shouldnt be this

NestJS Prisma MongoDB - Model ${model} does not exist in the database

app.module ``` import { Module } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service';...

Exposing FetchOptions Type with Better-Auth?

It seems that if I want the type definition of FetchOptions. I need to install @better-fetch/fetch
import type { BetterFetchOption } from '@better-fetch/fetch'
import type { BetterFetchOption } from '@better-fetch/fetch'
...

Anyway to support shared emails when using the username plugin?

Using BA for a game where players tend to make a lot of accounts and use a shared email between the accounts, BA currently does not allow this and was wondering if any work arounds?