Better Auth

BA

Better Auth

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

Join

bug-reports

help

Better Auth 1.2.9 + Prisma: P2000 error when login

Hi everyone, I'm using Better Auth v1.2.9 with Prisma as the adapter, and I'm encountering a PrismaClientKnownRequestError (P2000) when trying to log in using the Discord provider. Here's the relevant error log: SERVER_ERROR: PrismaClientKnownRequestError: ...

Advice: how to authenticate high-frequency endpoints?

I have an api endpoint which is being hit very frequently (/api/thumbnail/:provider/:id). That endpoint needs to fetch the account associated with that provider (e.g. getting/refreshing the access token) and then makes an api request to the provider (e.g. google drive) with the bearer token, etc. Alas, this is overwhelming supabase and I'm getting 504 errors 😦 What should I do? I'd like not to re-invent the wheel so perhaps someone can give me some advice?...

Middleware error on cluster deployment with Docker.

Hey guys I have a problem. My Nextjs app with better auth will not work correctly on my server enviroment. On vercel everything works perfect but on my server cluster it gets an 500 ssl error. This is my middleware code: ```import { betterFetch } from "@better-fetch/fetch"; import { NextResponse, type NextRequest } from "next/server"; ...

Add metadata to subscription using stripe plugin

In our application, a user can pay for other users. Once someone is tagged as a consumer, they are considered subscribed. To handle this, we created a view where a user can select other users to subscribe. ...

User role property in Organization plugin

Hey, I'm trying to setup the Organization plugin and I want to only let admin/superadmin roles be able to create new orgs using the allowUserToCreateOrganization However, the role property doesn't seem to exist on the user type, even though I have added the admin plugin and migrated the changes on DB. But I still get this error: Property 'role' does not exist on type '{ id: string; name: string; emailVerified: boolean; email: string; createdAt: Date; updatedAt: Date; image?: string | null | undefined; }'.ts(2339)...

How to generate a custom userID on registration

Can I provide a custom ID when a user signs up? (or ideally call a custom endpoint so that my database generates it naturally) context: my database uses a custom primary key type...

Issue sign in with Microsoft

``` ERROR [Better Auth]: { error: 'invalid_request', error_description: "AADSTS90023: Public clients can't send a client trace_id Correlation ID: correlation_id Timestamp: 2025-07-17 06:21:43Z", error_codes: [ 90023 ],...
No description

Getting INVALID TOKEN on Reset Password

I'm getting the URL, but when i go it always says INVALID TOKEN. The request is there, the token is there and is valid. The code snippet is attached in the images....
No description

onLinkAccount not triggered when linking anonymous user with social account (BetterAuth v1.2.12)

Hi, I'm running into a problem likely related to #1457. I am building an app using Expo ~53.0.9 on the client and Hono ^4.7.11 on the server. BetterAuth version is v1.2.12. ...

Cookies doesn't works in production mode

Hello everyone, my auth works fine in dev mode, I have an API with hono and a Front with Nextjs, my auth config looks:
No description

how can i link multiple oauth accounts from the same provider ?

For my app, I need to allow users to connect apps to their accounts through oauth and they should be able to connect multiple accounts from the same provider (ex. google), is it possible to do in better auth?

Not able to infer fields from extended core User schema

auth.ts: ```export const auth = betterAuth({ database: pgPool, user: { additionalFields: {...

additional fields on Social Providers

How can we pass additional fields, or additional context to the social providers sign up the same way we do on email and password sign up?

Session empty on Elysia server but works on Nextjs client

I have a Elysia server running on port 3002 and my Next.js client running on port 3001. When I signup I'm able to hit the server fine and create a session which is saved to a cookie, but whenever I try and make a request to the server the session is null. I have a guard on each route I want to check the session. I included credentials: "include" on my client request as well ``` export const AuthMacro = new Elysia({ name: "auth" }) .mount("/auth", auth.handler)...

Example with express

Do you have any example with express and protected routes in express? Could not find any example in docs...

any confirmation api available?

I'd like to use passkey auth with logged in users as a way to confirm certain destructive actions. Example: "Are you sure you want to delete your account?" After clicking "Yes", you need passkey auth to confirm. Do you have support for re-auth? especially in the context of confirmations?

Create Session Manually

Hi. I want to manually create a session when a user is authenticated using social provider, i am not using better auth on the client side and everthing on my backend. Is that possible?

Basic authentication emailandpassword, refresh accessToken using refreshToken

I am using basic authentication, emailAndPassword, adn plugin jwt and OIDC provider. I want to refresh accessToken using refreshToken till refreshToken is valid