Better Auth

BA

Better Auth

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

Join

bug-reports

help

Invitation email

I probably missed something but in the doc, I don't understand how the invitation email is actually sent. We can read this: ```ts await authClient.organization.inviteMember({ email: "[email protected]",...

build error -next js

Creating an optimized production build ... Failed to compile. ./node_modules/better-auth/dist/client/react/index.mjs Attempted import error: 'useRef' is not exported from 'react' (imported as 'React')....

Using custom schema for models, with prisma adapter.

Can you specify different database schema when using postgresql with prisma? For example, I have my user table in auth.users rather than the default public....

Installation problems

Hi, I'm trying to discover better-auth, so I start installing elysia, prisma and then better-auth, except that by following the doc, the "installation" part, from start to finish, I still can't understand how it works, the route localhost:3000/api/auth doesn't work and tells me NOT_FOUND
Solution:
I think it's normal that /api/auth is not found.. 😅 There is nothing there to do after all...

Stripe Better-Auth Plugin

I have an issue with the Stripe plugin (or maybe Stripe itself). Im implementing subscriptions and I'm getting conflicting events after a checkout in the Sandbox. First I get a OnSubscriptionComplete, I use the status to update the user's proStatus to "active"....

Throwing Error when try to login with existing user

`export const auth = betterAuth({ database: drizzleAdapter(drizzleDb, { provider: "sqlite", }), socialProviders: {...
Solution:
i think adding a small note in the migration guide might be useful
No description

Drizzle Postgres UUID

How can I force better-auth to use uuid's for id's and rely on the database to generate them with the drizzle adapter. The below doesn't seem to work. ``` advanced: { database: {...

Verification model not found in schema object

I thought that this error came from because it couldnt find the location of the auth schema but even after i put passed it into the config im getting the same error.
Solution:
figured it out, schema object had to be inside the adapter config not the betterAuth config 💔
No description

When impersonating a user, is it possible to set that session as the current session?

useSession after enabling impersonation still returns the original admin user, but as we use that for the whole dashboard, I'm wondering if we can make useSession return what we need here

disable magic link redirect and any other redirect

Hello, I am using better-auth with a Fastify backend, a classic REST api (port 4000) and for the frontend I am using next.js 14 (port 3000). So I managed to configure better-auth on the backend through a custom Fastify plugin. For the signin I am using the magic link plugin....

Session info isn't available fast enough on manual page reload, server sign in api needs reload

For any brave soul willing help me with this problem I posted to better-auths github I've included the info from that issue below Using SolidStart and Postgresql better-auth version: 1.2.7 OS: Microsoft Windows 11 HOME version: 10.0.26100 Build 26100...

Better Auth]: [#better-auth]: Couldn't read your auth config.

app git:(master) 15:10 npx @better-auth/cli generate 2025-04-15T19:11:29.250Z ERROR [Better Auth]: [#better-auth]: Couldn't read your auth config. Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again. at new PrismaClient (C:\Users\mehul\Desktop\Coding\Gridlock\app\node_modules\.prisma\client\default.js:43:11) I am getting this error and I am not sure what I am doing wrong. ...

cli not generating migration files due to cf bindings usage

im trying to set up better auth on cf workers (currently with hono, but would switch once this i would find a fix for this). i have the following betterauth config: ```ts // auth.ts...
Solution:
I recommend making a fake auth file and a real auth file. The fake one is just your better-auth config except for any fields which require ENV vars. ^ This file will be the one you would then use for the better-auth cli to read. The real one would be the one you currently have....

Next.js server actions auth

When I call from an action, the cookies are not sent - even if I insert “credentials”: “include”. Is there an example of how to call an external API via server actions?

Sessions not working

I have Hono as my backend and Next as my frontend. Hono and Next are on different codebases, I'm not using Hono in Next, I'm using it seperately. These are the issues I'm facing:...
Solution:
Marking this as solved as it's a problem made by me and not the library

updating schema field of type: string[] doesn't work.

I'm trying to extend organizations plugin. I'm trying to add projects field to of type "string[]". The problem is that Whenever I try to update it, it doesn't change. plugins schema: ```ts schema: { member: {...
No description

[Better Auth]: Couldn't read your auth config. Error: Cannot find module '$app/paths'

Has anyone else had this issue (see title) when running the npx @better-auth/cli generate cli command on SvelteKit? I can't figure out how to fix this issue.
Solution:
Duki, as mentioned by @KiNFiSH you probably need to remove any import that is called using sveltekit conventions and the run it. that's what I had to do

Tanstack Start how to handle session cookie

First the stack, im using Tanstack Start, Hono and Better-Auth The issue is when I hard reload or enter the URL manually, the cookie will not be read.. If its by client navigation it works correctly... ...

How to decode a cookie

Hey, i am new here and wondering how to decode a cookie to get it's value?

social signUp flow

I want to enable my users to sign up with Apple. I have additional required fields on the user model: ``` user: { additionalFields: { surname: {...