updateAccountOnSignIn
How updateAccountOnSignIn works, I have a genericOauth configuration, where user has extra role property, which can be change in future. I want to take that role and update the user whenever he sign in.
Intercept a email password sign-in at server?
I want to customize the behavior when an unverified user attempts to sign in.
Currently, the built-in requireEmailVerification automatically sends a verification email, but I'd prefer to just return a 403 status and let my frontend handle requesting verification emails explicitly.
Are there any hooks, middleware options, or configuration settings that would allow this customization?...
v1.2.6 and v.1.2.7 throws errors when logging in
Upgrading better-auth to v1.2.6 (using D1Dialect / Cloudflare D1 via kysely-d1) against a
verification
table where expires_at
is a TIMESTAMP/text column throws:
```
Oops!
Field expires_at not found in model verification...MongoDB Duplicate Key Session Error
Hey there, I have been facing this problem for almost a MONTH now and still couldn't find a solution to this.
When I log in to my BetterAuth account, remove the session key from cookie, refresh the page and then log in again, I get an error from MongoDB. That's because there is already a session created for this user. So I have to manually remove session from db to log in again.
But I don't understand how I could fix this error as it makes impossible to have more sessions for one account....

Setting cookies with custom plugin auth
Hi, I'm having a few issues with setting this up the way that I want it to but I may be approaching it from the wrong way. I am using another application that I want users to be able to single click sign on into but it is not an Idp or oauth provider. Instead it providers a token in the URL that I can decrypt.
The current imagined workflow is as follows:
1. User clicks button
2. Gets sent to
/api/auth/test/sso
...BetterAuth GitHub OAuth Creates Only Verification Records, No User/Account/Session
```bash
✓ Compiled /auth/signin in 9.6s (9870 modules)
GET /auth/signin 200 in 9866ms
○ Compiling /api/auth/[...all] ...
✓ Compiled /api/auth/[...all] in 2.5s (5762 modules)...
is BETTER_AUTH_SECRET safe to expose on the client?
title, i guess it is if we're using the react hooks?
How to handle phoneNumber.sendOtp errors ? Only 500 is returned
Hey, I wanted to know if it's possible to handle errors that happen in the sendOtp option of the phoneNumber plugin. Currently, throwed errors are sent as 500 without proper error message.
If the user provides a malformed input, I may want to be able to return a specific error for that, not just 500.
Does someone had this problem before, or can someone help me?...
Use auth.api as request only?
I'm using auth.api across multiple apps. They don't necessarily share the same DB, but I keep getting a "this relation does not exist" error when trying to use it.
Using just fetch works without a problem. Any suggestions...
Cant get listUsers in the admin plugin to work
const usersQuery = useQuery({
queryKey: ["users"],
queryFn: async () => {
return await authClient.admin.listUsers({
query: { limit: 10 },...
405 When signing in after deploying
I’m having an issue where when signing in, it uses whatever URL I’m navigated to, like if I’m using a Vercel preview URL it does /auth from that URL, instead of using my preset BETTER_AUTH_URL
Anyone else having a similar issue?...
trpc
Hi, I want to "connect" my electron app to my nextjs server using better-auth with an admin plugin. How would I be able to connect an account to the electron app then get the users permissions to then do some things depending on these permissions? For login in would my best choice be an electron deep link?
Environment Variables not found
Hi, I deployed my Next.js project using Vercel, but in production I'm getting these messages.
Checklist:
I checked my environment variables in the host.
...

Unable to check permisions
When I do this
```
export async function updateUser(id: string, payload: Partial<User>) {
const canCreateProject = await authClient.admin.hasPermission(
{...
Unable to set cookies in hooks
I'm not able to set normal or signed cookies in hooks.
```js
hooks: {
before: createAuthMiddleware(async (ctx) => {...
Shareable links
I’m planning to make parts of my dashboard shareable as reports — similar to how you can share files in Figma.
Has anyone already implemented something like this with better-auth?
I’d love to hear your ideas on how to approach this.
Currently, I’m using Next.js....
Privilege elevation?
Hello,
First of all, this is a very nice library — thank you for your work!
I had a question: is there a way to implement temporary privilege elevation?...
No page refresh after sign in or sign out?
I have created a simple Next.js application
- I use sign (with email/password) with a server action that creates a cookie (from auth.ts)
- I use sign out with a client action (from auth_client.ts)...
[OIDC] Post-consent authorization in refresh token flow
- BA as OIDC OP (OIDC provider plugin)
- Auth.js as OIDC RP
client.oauth2.authorize(...)
with offline_access
scope + prompt=consent
parameter works the first time (redirects back to client after accepting consent with client.oauth2.consent(...)
) along with a refresh token, however subsequent requests trigger a 500 error. They work again if I delete the corresponding record in the oauth_consent
table. What am I doing wrong in the flow? Can share more details as needed (query parameters passed to .authorize
, etc.)...Open api with exchange token
Hey!
I need to create a public API (machine to machine) where our users will have to generate a key. the key is created by a user but attached to a company
(1 user belong to many company, 1 company has many users)
This is the flow:
1. user creates a key "A" in the context of a company...