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 do I setup Discord OAuth2?

I have a Hono API running on localhost:3001 and a NextJS app on localhost:3000 On the server I have setup trustedOrigins and allowed localhost:3000 On the client I have set the baseURL to localhost:3001 And in the Discord Developer Portal the redirect URI is set to localhost:3001/api/auth/callback/discord...

How to add organization details to JWT claim?

Wondering how we can add these details via the jwt plugin?

404 Error for /api/auth/sign-up

When attempting to access the sign-up endpoint via /api/auth/sign-up/email, the SvelteKit app throws a 404 error: ```bash SvelteKitError: Not found: /api/auth/sign-up/email at resolve (/home/ubuntu/v2/frontend/node_modules/@sveltejs/kit/src/runtime/server/respond.js:582:13)...

The edge runtime does not support Node.js 'net' module.

I couldn't find work around for this fix. Here are my middleware.ts and auth.ts files....

"[object Object]" is not valid JSON

i am using nextjs 15.3.1 app router with typescript, betterauth 1.2.7. ```tsx import { auth } from "@/lib/auth"; import { headers } from "next/headers";...

getSession() doesn't return user table additional fields

I cannot get changedFirstPasswordAt field in the hooks.server.ts from user table. Any idea ?...
No description

requests to /api/auth/* hanging for 500s before cancelling when calling to prod URL

I've set up NestJS and better-auth according to https://github.com/laakal/nestjs-better-auth-template, and am hosting it on Railway at https://thewebapi-production.up.railway.app Whenever I run authClient.signUp.email(), the request goes through, but gets left on "pending", both in the dev console and when i tested it on Postman. I don't know whether its a CORS issue or something to do with my implementation of better-auth...

Google Oauth + Expo

Just want to confirm if anyone has got Google oauth sign in working in production in expo 52. I know i've set it up correctly and oauth works fine locally. In prod, sign in just hangs after I select my google account

Weird behavior when rememberMe is false.

When logging in with rememberMe: false, the session cookie is created and stored correctly (verified in browser + DB), but /v1/session (or /api/auth/get-session) returns null. With rememberMe: true, everything works fine. Both od the endpoints returns the session. What i've tried: Cookies are correctly set (better-auth.session_token, dont_remember) and sent with credentials: "include". Headers forwarded correctly in /v1/login, including Set-Cookie....

send additional headers

is there a way to pass additional headers? Doing it like this throws an error and seems to completely override headers: ```ts //client await authClient.forgetPassword({ email: value.email,...

Vercel.app for previews

Hi, I'm using BetterAuth in production across two different subdomains: api.example.com (where BetterAuth is hosted) and site.example.com (I've configured cookiesubdomain, etc.). Everything works perfectly in production, and I'm hosting with Vercel. However, when I create new branches or run tests, Vercel assigns preview domains under .vercel.app, and at that point authentication stops working....

401 error Nextjs(cookies not being sent)

To Reproduce Using express backend with drizzle My apis arent being sent from frontend to backend, in nextjs, tried using with crenetials also ...

Refresh the page after authClient.signOut()

I have something like ```ts const handleSingOut = async () => { await authClient.signOut(); router.push("/login");...

extending user data from another table

we store our user's profile images in a "files" table with a join table "user_files". i'd like to override the default user "image" with the s3 key from the files table. is this possible?...
Solution:
You can just set the s3 key to the image field once the img is uploaded to your Db right?

Client side - get all permissions

Hey all, is there a way to get on the client side all of the resource permissions that the current user has?

Send additional data Google/Apple Signup

I want to send the onboarding data along with the signup for Google/Apple . How can I do this? With email provider I can just use: ```typescript signUp.email(...

Implemeting Notion OAuth2

Hey! I have tried everything now to implement the Oauth2 flow for Notion, but I always get this error. Anyone has any ideas what could cause it?
No description

Stripe Plugin + AI Usage Limits - Anyone done this?

Hey everyone! Is anyone here using the Stripe plugin for implementing AI feature limits in a next.js app? I'm looking to integrate subscription-based AI usage limits (like chat requests, token limits, etc.) with the Stripe plugin and wondering if anyone has already tackled this. Would love to hear about your approaches or share ideas on how to best implement this!...

Best way for a plugin to extend session object

We’re trying to extend the session object in the after hook using createAuthMiddleware. However, when we fetch the session on the client, it still uses the original session type. What’s the recommended way to safely extend the session object with custom attributes while maintaining type safety? We came across the customSession plugin, which overrides the /get-session route — but is that really the recommended approach for all plugins? It feels a bit hacky for something that should be more common....
Solution:
Yeah I would recommend a new endpoint if using customSession isn't an option for you.

passing additional data from authClient to server betterAuth instance

is there a way to pass additional data from client to server when sending emails? For example when sending reset password email, instead of just sending the user's email and callbackUrl as data i also want to send locale which isn't part of the request body so i can generate the email with appropriate language