Better Auth

BA

Better Auth

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

Join

bug-reports

help

Is Better Auth a good choice on Cloudflare with D1?

I have a SvelteKit site hosted in Cloudflare's serverless Workers infrastructure. The database is Cloudflare D1. Unfortunately each DB query, or batch of queries, requires a network roundtrip which averages 100ms and can reach 300ms. So I really need to minimise the number of roundtrips, by batching queries. Is Better Auth a good choice in this environment? Does it allow typical flows (accessing a protected page, logging in, creating an account) to be completed in 1-2 roundtrips to the database? To what extent can I control this? Thanks! Better Auth seems brilliant, if I can resolve this q....

Using Microsoft Entra id b2b with better auth

Tech Stack- 1. Nextjs 2. azure Entra id (for b2b use cases with organization/tenant support). 3. better-auth 4. MongoDB...

Memory Leak?

I am using v1.3.2 on NestJS and I’m noticing a memory usage pattern that increases steadily with user traffic until it reaches 95%+ then repeats again. Is this a known issue? (I saw someone report this for the custom session plugin, I’m not using it but I’m using the jwt plugin however)

OpenAPI plugin is not working in NestJs

I tried using the openapi plugin in nestjs I am getting a blank white page for the route http://localhost:4002/api/auth/reference

ERROR [Better Auth]: Failed to initialize database adapter debug

Is there any way to debug the message: ERROR [Better Auth]: Failed to initialize database adapter I am getting this error but I am able to manually create my database adapter and use that perfectly....

Can't create Organizations using convex

Hey. I am currently starting an app with nextjs and convex. I had already setup auth and github + email and password no problem. I went through the recommended way (using a betterAuth convex component). But when trying to create organizations with authClient i'm hitting an error: ``` Sep 29, 17:32:15.417 failure ...

When calling auth.api.getSession, why is the user key inside the session object sometimes undefined?

Server-side rendering a page on Next.js: ```typescript import { auth } from "./auth"; import { headers } from "next/headers";...

How to implement a custom response interceptor with Nest Better Auth library?

I'm using the Nest Better Auth library and need help implementing a custom interceptor to transform the library's default response format to match my application's standardized response structure. Current Issue The Better Auth library returns responses in this format: ...

Column account.type / account.provider does not exist

Not sure if this is a bug, followed the getting started guidelines. Brand new setup with next.js + supabase + prisma: package.json...
Solution:

How to invite user to organization

@Better Auth How to invite user to organization if user has no account yet and sending invitation will cause error. Current organization doesn't have owner and I want to invite new owner that doesn't yet have account

how do i get the name lol

like if i do getSession or useSession, i get session.userId or user.id. now if i want to use the accountInfo then i need accountId. where do i get the accountId

User Session in SSR (Next.js)

I have a separate backend in Nest.js, and I am using Next.js for the frontend. I want to fetch the user session and user details in SSR, but when I do authClient.getSession(), it returns {data: null}, but it works fine in client side. I have read other posts as well, but I didn't understand....

Better-Auth Stripe Subscription Issue

Problem: - Stripe subscription upgrades work correctly (plan changes in Stripe dashboard) - But the Neon database still shows the old plan (e.g., "gold" instead of "platinum") - Database and Stripe are out of sync...

oAuthProxy plugin doesn't work

Hello everyone, I created this issue in better-auth Github: https://github.com/better-auth/better-auth/issues/4953 I've spent all day trying to figure it out but I can't get oAuthProxy plugin to work. Maybe I'm missing something obvious, if so please point it out! ...

auth.api.getSession() returning null even when the cookies are being sent.

Hey devs, for some reason in a API route in NextJS im getting the current session but for some reason it comes out null . ```ts export async function POST(request: NextRequest) { try {...

Expo social login don't refresh the session

Hi, I'm trying to do the login with Google and expo and I have to do the sign in twice because the first time don do nothing

Does anyone have a good example of how authClient.admin.hasPermission works?

I've tried everything, searching, using AI, but nothing makes it work in my code. How should this be used correctly? Could some good soul give me an example of a complete configuration + example of use?
Solution:
You can't force cast as BetterAuthOptions as that will break inference in your auth config.

Get Zod Schema from Better-Auth to use in form libraries

Is there a way to generate Zod schema or get Zod schema for better auth endpoints? I am using Hono.js. I am currently defining Zod schema on client, but obviously this causes the problem of schema drift....

NextJS + Express (Best Practice?)

Hello everyone, I’m currently migrating from NextAuth to BetterAuth, but I’m running into some problems – especially when it comes to fetching the session server-side in Next.js. I’ve documented my current setup and my BetterAuth implementation in Notion for reference....

SignOut doesn't redirect

Why does this not redirect IMMEDIATELY <DropdownMenuItem onClick={async () => { await authClient.signOut(); }} >...