Better Auth

BA

Better Auth

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

Join

bug-reports

help

findOneAndUpdate in mongodbAdapter returns inconsistent result shape

Hello, first of all I want to say that I love the framework. As the result I've have been migrating to it, but I encountered the following issue. I have also created github issue (https://github.com/better-auth/better-auth/issues/2508). There are more info in the page. Hi, I'm encountering an inconsistency with db.collection.findOneAndUpdate() in the mongodbAdapter. For some collections, it returns the updated document as expected. However, for others—like the users collection—it returns a result object in the following shape: { lastErrorObject: {n:1, updatedExisting: true}...

authClient.admin.removeUser doesn't trigger beforeDelete

I'm using the admin plugin. It has authClient.admin.removeUser functionality. the problem is that I set up user beforeDelete to delete all of the images from my s3 bucket before removing the user and it doesn't work. It works if and only if the user deletes himself manually. user deletion from the admin side: ```ts async function handleDelete() {...

Data Types MSSQL

Hi all. Not sure if this is a bug or just a lack of knowledge on my part. I have a next.js project using a mssql db and have generated/ migrated schema as per docs for all of the plugins. I've been setting up forgot password and update password but hitting an error with data types. For forgot password, the error occurs when the user has clicked on the link in the email (verifying the token??), and with update password, the error looks to be a call for accountId when it's writing the new password to the db. Error: The data types text and nvarchar are incompatible in the equal to operator. The schema has a number of fields as 'text' such as the tokens, accountId's etc but mssql no longer supports text as a data type so the db errors out on api calls that use these fields. I've manually updated the columns in my db to be varchar or nvarchar which has resolved the issue. I updated better-auth from 1.2.3 to 1.2.6 which also meant the twofactor verification failed as the verification table is also set up with text....

Not Equal filter not working on nextjs with prisma.

Hi guys, i've noticed a bug while trying to query all users except the ones with a specific role. On GitHub i've seen that a user already reported that: https://github.com/better-auth/better-auth/issues/2468 ...

db is not exposed in context

According to the docs at: https://www.better-auth.com/docs/concepts/plugins#what-can-a-plugin-do, the context object contains the db instance, like kysely. For me, it does not, please see the attachment to this post. Not only in my editor but also console logging the context object does not reveal the db instance. What do I need to do to expose the DB instance? I need to make joins due to performance reasons and I dont think the adapter is capable of it....
No description

Error Generating Types with openapi-typescript

Issue Description: Running the command bunx openapi-typescript --make-paths-enum --immutable results in the following error:
Error: #/paths/~1sign-in~1social/post/responses/200/content/application~1json: invalid property required. Expected Schema Object, got Array
Error: #/paths/~1sign-in~1social/post/responses/200/content/application~1json: invalid property required. Expected Schema Object, got Array
...
No description

Cannot cancel a trailing subscription

I'm trying to cancel a trialing subscription, by passing the subscription id in cancel function, but I receive a 400 response saying that the subscription cannot be found, but when I check my DB it is definitely there and the subscription Id matches. Am I supposed to cancel trials differently than active subscriptions?

Session schema missing from open API spec generation

I'm using the following code to generate open API documentation, however I noticed the reference to #/components/schemas/Session is missing? auth.api.generateOpenAPISchema()...

[Better Auth]: Error 4816

I am using simple setup for better-auth trying it with Bun.serve. const server = Bun.serve({ fetch: auth.handler, port: 3000,...

stripe subscription event hooks

1. None of the Stripe Subscription Event Hooks are being triggered. 2. No Error Message 3. See attached image the onEvent hook does work... if I implement them myself and in the future better-auth hooks start working there is going to be pain when double spends happen etc....
No description

Stripe plugin - upgrade() creates two subscriptions instead of updating existing one.

I have two plans, "Starter" and "Pro". If a user upgrades their plan from "Starter" to "Pro" with the upgrade() method, there becomes two active subscriptions at the same time in Stripe (see image attached). This will bill the user for both plans, which isn't correct.
No description

`drizzleAdapter` is not handling `ne` operator

Hello, currently the convertWhereClause (L133) in drizzleAdapter is not handling the ne operator and fallsback to eq by default. Version: 1.2.7 This cause invalid data being returned on filters. See below example:...

Empty headers in verifyPhoneNumber API

I am receiving empty headers when I'm expecting it to to have better-auth.session_token set-cookie
No description

Stripe plugin create a new customer on subscription.upgrade click.

I have 2 different buttons to subscription.upgrade in my app. After user is registered customer is created in stripe according to createCustomerOnSignUp: true, in plugin config. But when I navigate to one of my 'Subscribe' buttons and click on it -> subscription.upgrade just creates new user in stripe instead of triggering checkout session: ```sh 2025-04-20 14:38:59 --> customer.created [evt_1RG3hf4FS9Rcg327BHPwlIez] 2025-04-20 14:38:59 <-- [200] POST http://localhost:3000/api/auth/stripe/webhook [evt_1RG3hf4FS9Rcg327BHPwlIez]...

change email does not update the customer's email in stripe

When executing an email change, the new email is not updated in the stripe's customer table in the dashboard. Is that something that is meant to be done manually? I would have expected BA to check if there is a customer Id set on that user and if so, trigger the change in stripe as well. Question is just, should it happen right after the change requested got accepted by the user (from the sendChangeEmailVerification email) or after the new email got verified. That could maybe depend on the `re...
Solution:
Hey are you able to open a github issue on this? In the mean time you can hse hooks to manually update users...

Period fields not populated after stripe subscription

Hello, period_start and period_end fields in the subscription object are not populated after a user subscribes via subscription.upgrade. Stripe : 17.7.0 Better-auth : 1.2.7...
Solution:
Good in v1.2.8-beta.3 : Solved

Website is not available

The Better‑auth.com website is currently inaccessible in the UAE. I’ve tested it with several internet service providers: it was reachable as recently as last week, but for the past few days it has been returning a persistent DNS error.
No description

Starting v1.2.6 `database.generateId = false` still inserts Id into the verification table

On v1.2.6 onward (was working in v1.2.5), when setting database.generateId = false Id is still being generated for the verification table. I'm using pg with kysely-postgres-js ```js...

NextJS trailing slash ignored

Per title, if I set trailingSlash: true in my next config, I would expect better-auth to respect those same rules, as currently every request just hits a redirect as better-auth is querying URL's without a trailing slash