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 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...

Mongodb indexable?

So I was reading the optimizing for performance guide. Is it possible to index the fields in mongodb for faster auth times?

Google auth on plasmo browser ext

Is it possible to use plasmo and have google auth with a plasmo framework extension? I see that the example uses password and username, but I’d like to add google auth. What would be those steps? I have a full Nextjs website with the Google auth setup already...

Custom format for API Key

I need my API keys to be a UUID v4 (the software that it interfaces with requires the keys to be formatted that way) - how can I do this with the API key plugin?
Solution:
Solution: ```ts plugins: [ apiKey({ customKeyGenerator: async () => {...

Soft Deletes

Hi! I had a broader question around how BetterAuth is intended to support soft deletes across different entities (users, organizations, invitations, etc). In our system, we soft delete records by setting deletedAt to a non-null val rather than hard-deleting them. I'm running into some challenges where BetterAuth’s core logic doesn't seem to account for soft-deleted entities. For example, when creating an invitation, if a user’s email already exists (even if soft-deleted), it throws an error. Similarly, creating users or organizations could conflict if soft-deleted records aren’t ignored during validation....

inferAdditionalFields

What is the purpose of inferAdditionalFields (this is mostly rhetorical) because the returned user object from signin email doesn't have additional fields even if specified and if you don't put inferAdditionalFields in your client config the fields are added by default to the user returned in the session. I am confused on the purpose because it doesn't seem to do anything. I am likely doing something wrong somewhere....
No description

Extend type user

```user: { changeEmail: { enabled: true, sendChangeEmailVerification: async ({ newEmail, url }) => { ///...
Solution:
Found a quick fix
export type User = typeof auth.$Infer.Session["user"];
export type User = typeof auth.$Infer.Session["user"];
adding this in the auth.ts

Manual User SignUp

I'm only using google for signup . But suddenly my team asked me if we could manually signup user . Is there any way to do that? As google provides several data that are need for the user, account table and other 2 tables.

Get session call failing Safari

Hi, I’ve recently setup better auth with nextjs, using the drizzle adapter and nextCookie plugin. I wrote my own plugin for steam authentication (OpenID 2.0), which seems to be working good. However, one weird bug I’ve seen is that on safari, the get session call made when the user clicks my sites sign in button throws an error with status 0 and status text as an empty string. Any idea why this is happening? Thanks!...

How to get a bigger profile image from google and facebook?

I'm trying to get the image directly from oAuth2 and use it in my user's internal profile. However, I've been only getting a 50x50 image. Does anyone know if getting a higher res photo is possible?

How to seed initial admin user on develop/staging/prod to start creating users

I am having trouble creating this initial step for me to progress on, I am also looking into using both the admin and organization plugins to work hand in hand hows to make this possibel

Captcha verification failed

I keep getting "Captcha verification failed" after adding Cloudflare Turnstyle captcha using Nextjs: ```import { Footer } from "@/components/internal/footer"; import RegisterForm from "@/components/internal/forms/register-form"; import Navigation from "@/components/internal/navigation";...

Don't understand how to configure OIDC with an existing provider

I don't understand how to configure better-auth to connect to an exiting OIDC provider. I have an OIDC provider at my company. I wrote the following to register it in auth.js: ```javascript import { betterAuth } from "better-auth"; import { sso } from "better-auth/plugins/sso";...

How to Prevent Automatic Resending of Verification Email on Login with requireEmailVerification?

I have a question regarding the requireEmailVerification option. When I set requireEmailVerification: true, the backend correctly returns a 403 response if a non-verified user tries to log in. I handle this on the frontend by showing a verification modal. However, I’ve noticed that BetterAuth also automatically resends the verification email to the user when this happens. What I want:...

stripe subscription list 401

When I try to list the active subscriptions I get and 401 error. Tried using the doc example. Any idea? ```js...
Solution:
it suddenly worked after some restarts, i dont know how

Stripe customer portal "select certificate" alerts popping up multiple times

I'm wondering if anyone else has this issue during local development. When I call BA's cancel subscription function and redirect the user to stripe's customer portal I receive a lot of alerts asking me to select a certificate. Where does it come from?...

Extending the Organization plugin

I would like to add functionality to the organization plugin, is there a way to extend it? Or do I just add features to the original plugin? My idea is to use groups to, well, group users, where a user can join multiple groups and an org can have multiple groups, with a simple management API. Creating groups, deleting groups, updating groups / group members. These should not be used for permissions but simply for organization of users...

Notion OAuth in Remix

Hey! Has anyone managed to make Notion OAuth work in their better-auth config? I am trying to do it but I always get oauth_code_verification_failed on the client