Better Auth

BA

Better Auth

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

Join

bug-reports

help

Large cookie size breaking login

This seems to be the same question that's already been asked, but it was a few months ago. I want to check if there's been an update since: https://discord.com/channels/1288403910284935179/1357381653067989214/1357381653067989214 I don't see why it's important to store the image in the cookie and then go over the browser limits. What we were able to do on NextAuth is just remove the image from the cookie. We store the image in the database, but it doesn't need to be stored on the cookie level. I'm curious, is there some way to do this in BetterAuth? This isn't a huge headache because this is quite a bad bug....

Renamed email field via auth config results in auth error

Using better-auth@1.3.8-beta.3 with prisma adapter I've renamed several columns via the auth config (to use snake case column names), and also changed the database column names (via prisma migration). But upon logging in there's a query error thrown which is attempting to use the custom field name email_address instead of the prisma model name email. auth.ts...

email sign up fails with error: "FAILED_TO_CREATE_USER"

Hi community, I have this issue where I constantly get the error FAILED_TO_CREATE_USER with an error code 422, when i try to sign up a user via email. I have added a screenshot of the network error logs. I couldn't figure out what I am doing wrong. Did anyone experience something similar and can help? ...
No description

Trying to connect kysely-neon with Better Auth but failed.

I don't know what causes this, but apparently coming from the configuration. I already created my src/lib/auth.ts file inside my SvelteKit project. And this is my code: ```typescript import { betterAuth } from "better-auth";...

Have anyone manage to get OIDC working with genericOauth

i keep getting this error ``` 2025-08-28T15:24:05.992Z ERROR [Better Auth]: State Mismatch. Verification not found { state: "SAWTsHvhONj2IiZKdnrNB98AXUhs1X3L",...

Email Verification Email is not Sent

I've been trying to add emailVerification to my app for some time, but didn't get it working. My function works well, doesn't have issues when trying it externally from better auth. But when I am trying to make it send the email, it does not work. ( Added prints and it looks like the function isn't called ) ```ts emailAndPassword: { enabled: true,...
Solution:
It looks like the verification email isn’t being sent because the configuration is misplaced. According to Better Auth’s documentation, options like sendOnSignUp and sendVerificationEmail should be defined under the emailVerification configuration rather than inside emailAndPassword. In your snippet, they’re currently under emailAndPassword, so the framework isn’t triggering the verification email on signUp [1], [4]. To fix this, move these options to the emailVerification object in your auth configuration. This should ensure that the email verification process is correctly triggered on signUp. Sources:...

Create a Magic-Link from the server

The documentation for creating a Magic-Link for signing in with auth.api.signInMagicLink mentions we have to set the headers ("This endpoint requires session cookies"), but I'm not sure which headers have to be given, when I'm doing the call from the server? Basically what I'm trying to do is using the magic-link as a kind of "invite" for users, so I have some script in my backend which automatically sends the magic-link to the new user. What should be the content of that header? it says it's for cookies, but I'm not using cookies when doing a call from the backend on the behalf of another user...
No description

Unable to create plugin

I'm currently using admin plugin with phone plugin , i need a way to setup custom endpoints that enables admins to create users with a phoneNumber without otp and a role , i know it is going to be possible with custom plugin and i can directly tap into the db instance of better auth , but unfortunately , when i try to setup , there is a issue that i am encountering
Solution:
This did work once i made the function async

Migrate from supabase auth -> betterauth for 2 million rows

We're looking to experiment with migrating from supabase auth -> betterauth but we have about ~2 million rows. Any tips on how to optimize this migration? Following: https://www.better-auth.com/docs/guides/supabase-migration-guide...

Server-side calls without request headers?

Hi, I was wondering if there’s a way to create users, send invitations, etc. purely from the server side, without having to pass through the request context or headers to the authClient.api.* functions. For example, is there a way to create an auth client that has a server secret token baked in or some other means of authentication that's baked into the client? Right now, if I want to build something like a generic user-invitation service, it feels awkward to either (a) not have the request handy, or (b) thread headers all the way down through multiple layers of my app just so I can call Better Auth in cases where, perhaps user invitations are sent as part of a larger complex workflow. What I’d really like is a way to make these kinds of trusted, server-initiated calls on behalf of the application itself (not tied to a logged-in user)....

How to get client to immediately update activeOrganizationId after creating an organization?

Hello! I have some code that redirects users to setup an organization after they first sign up ``` const { data: session, isPending } = authClient.useSession();...

Plugin Schemas

If I use prisma adapter, do I need to use my models in the plugin, rewrite the schema, or is there an automatic solution for creating a schema from prisma in json?

OIDC Login page question

I’m building an internal-only OIDC provider with Hono on backend.mydomain.com. All consuming services will be on the same parent domain (*.mydomain.com) and expect OIDC-compliant JWTs. Can I keep the actual login UI (username/password form, MFA, etc.) on a separate host—accounts.mydomain.com—while still having the OIDC discovery, token, and JWKS endpoints served from backend.mydomain.com? In other words, is it valid (and what do I need to configure) so that:...

How can I run a hook after the Google OAuth flow?

Hey, I'm in the process of migrating my previous custom auth logic to better-auth. I'm using better-auth on my Hono backend. I need to execute logic after the user completes the Google OAuth flow, I need to recreate a Postgres materialized view adding the newly create user. Previously I just had this logic in the handler itself but now I'm not sure where to add this logic. I'm trying to add this logic to a hook like so: ```hooks: {...

However, on devices other than iOS, authentication works without problems.

it takes me to the home page, but without logging me in. I tried this on different browsers on my iPhone, whether Safari, Chrome, or Brave, and none of them logged in or logged in, even though it took me to the home page without any errors. However, on devices other than iOS, authentication works without problems. Are you using session cookies? yes I use (I think this is the problem because I am using Lax=none because the domain of the frontend and backend are different.) ...

pckce in expo

i have a question. the ids4 is in my infra. with custom auth endpoints like token, refresh, user endpoints. now i want to use better_auth pkce flow in my react native expo project. is it possible

Cookies not being set on Vercel (works on localhost)

Hi! I have a Turborepo application and it works perfectly on localhost, but on Vercel the cookie is not being set. `apps/web apps/api ...

Any idea on how to implement suspicious login detection?

I was thinking on using the database hook on session creation but if there is any other way that is better then please let me know

organizationId gives an error when passing to getFullOrganization() function

I have a SvelteKit project. I believe I have set up everything as in the docs. The create organization function works as does the get active organization function, but getFullOrganization function is not working. Any help appreciated!
No description

Update user with additional fields

I've defined additional fields on my User struct ```ts additionalFields: { description: {...