Better Auth

BA

Better Auth

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

Join

bug-reports

help

No Redirect after MCP OAuth

Just created this one: https://github.com/better-auth/better-auth/issues/2914 Lmk if I missed anything. Currently this kinda blocks our MCP release as no test user was able to install the server themselves lol. Would be great if someone could look into it....

Verifications are created multiple times

I'm using google oauth2 in my elysia app, when I complete the oauth2 flow, I saw there is one more verification record not being consumed, so I tried multiple times, I found that oauth2 url is being created two times, sometimes oauth2 url is created one time but the console show the error scenrio 1: verifications being created two times { url: "https://accounts.google.com/o/oauth2/auth?...",...

Verification doesnโ€™t appear in the db

I am not getting the verification set into the db, although I get the email sent via resend, and I can verify my account with that link as well. To reproduce, just simply set up email verification based on the docs, I am using 1.2.8 of better-auth...

numeric additionalFields defaultValue field does not work

``` additionalFields: { credits: { type: "number", required: false,...

SyntaxError: "[object Object]" is not valid JSON on Google oauth callback

I'm trying to setup google oauth login and I'm receiving a strange error when the provider calls the callback URL. What I get in my server logs (I've added some logging in the library code): ``` state o2c5WeQomqhNbjem-NPwSEbeDk3Eg_J6 data {...
Solution:
Sorry, this was a problem on my side. I had the kysely plugin ParseJSONResultsPlugin enabled on the adapter

Doesn't work in Express if I change the path of app.all(...)

The default one is app.all('/api/auth/splat', toNodeHandler(auth)). When I change to app.all('/auth/splat', toNodeHandler(auth)). It throws an error of unknown. I am using turborepo btw. Both backend and frontend set the correct path since it successfully called, but just the auth service panic. ``` 2025-06-01T18:52:34.676Z ERROR [Better Auth]: Error Error: NOT_FOUND...

`member` & `pending` not defined in schema since 1.2.9 update

Hey there, just updated to 1.2.9 (new mcp server incoming soon ๐Ÿ‘€) - but after a schema migration it now fails to find the freshly added member & pending references from the organization plugin.
No description

auth on server

I use next.js and better-auth. And it throws an error when I try to authenticate user on server side. ```typescript const session = await auth.api.getSession({...

Signing in when already signed in shouldn't create a new session

I know it's contrived, but if you're already signed in but still call the authClient sign in function, a new session will be created in the database. My expectation is that it would just return an error saying "Already signed in". Basically it doesn't seem idempotent and neither does sign out....

delete user with password doesn't work if sendDeleteAccountVerification is set up

As the title says. I'm trying to implement user deletion with both: password (for credentials & phoneNumber users) & email verification (for OAuth users). I set up sendDeleteAccountVerification, deleting account by sendingDeleteVerification works, but by using password doesn't work. It just gives success state (if the password is correct) but doesn't work.. auth.ts: ```ts user: { deleteUser: {...

In MYSQL mode, wrong column types are generated

Auth object: ```ts export const auth = betterAuth({ database: drizzleAdapter(db, { provider: "mysql",...

import mcp plugin return error

import { mcp } from "better-auth/plugins"; cannot find the plugin, try with the latest beta....

Redirect Callback Bug

Hi, I am using linkSocial and want to handle any errors on my custom page rather than on the default api error page. I discovered that in the parseState errorURL is being set in case it's not in the state object. This leads to the error url of redirectOnError always being this default error url see here....

Incorrect Response Data

Hi there I have setup better auth to be snake case but when i use ```typescript const sess = await auth.api.listSessions({ headers: c.req.raw.headers...
Solution:
There isn't a solution which will solve all cases of returned data, however the primary data you'll receive is likely from useSession / getSession, which fortunutely has a way to suit your needs. I recommend checking out the custom session plugin which you can return lowercase names as needed....

Bearer and Two Factor

Hi guys, I post this here before to do an issue on github to have your feedback. I setup Better Auth with plugins bearer and two factor. ...

impersonatedBy missing in admin session

I am using the admin plugin for impersonation. When i get the current data with auth.api.getSession(), the TypeScript type for the session does not include the impersonatedBy field, so when I try to access it for conditional rendering I get a TS error. At runtime it works correctly, and the impersonatedBy field is present in the JS session object as null or with the correct ID. How can I make my auth instance aware I am using the admin plugin so it knows impersonatedBy is in the session object?
Solution:
Hello, types should had inferred correctly if you're using auth.api and have included the admin plugin. May I see the useAuth hook? @chris...

Overriding TOTP Period Causes Unauthorized / Invalid Two-Factor Cookie Error

When I override the default TOTP period (e.g. from 30 seconds to 60 seconds) in the Better Auth 2FA TOTP plugin configuration. The attempt to verify totp code end up in resulting in Unauthorized response and an Invalid two-factor cookie message. If you dont override the default period. The code works fine. To Reproduce...
No description

Generating schema from some plugins introduce bugs.

Using the organization plugin, its invitation and member tables schemas are introduced with a bug. You cannot use member & pending since they are blocked scoped variables and not able to be used until after they are fully declared. Removing it will allow the schema to build, but I am not sure if that is the intended use.
No description

Adding admin plugin causes "The inferred type of this node exceeds the maximum length the compiler"

When I add the admin plugin to my list of plugins it results in the error:
The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed
The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed
...

2FA / TOTP "trust device" bugs

Quick summary: - When TOTP is entered, user chooses to trust device. - trust_device cookie is set. Expiration date looks like it's 30 days out (docs say it should be 60) - log out - Log back in; TOTP is not requested (good!)...