Better Auth

BA

Better Auth

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

Join

bug-reports

help

Drizzle TypeError: not enough arguments

i just started my instance today and all of a sudden fails to boot complaining about mysql key not provided. ive been using sqlite with drizzle all this time database: drizzleAdapter(dbClient, { provider: 'sqlite', schema: schema,...

Can't get someone elses github project to work

Im trying to start https://github.com/outpoot/rugplay yesterday everything was working suddenly not anymore i can't seem to find what the problem is using https://192.168.178.223:5173/...

Is there a way to add more infromation on sign-up?

I'm trying to add a new field in the user signup aside from the defaults. I wanted to add a field like invitedBy on the client, something like this: ```await authClient.signUp.email({ name:, email:,...

Handling auth on server-side?

I'm using React Router v7 (Remix), and I want to authenticate on the server. But it seems like BE doesn't support server-side auth. Is this really so?
Solution:

Email OTP

Hello, is it possible to also provide name, password, image on a signup OTP similar to email signup?...

Using the auth object on server side Nextjs

Hey BetterAuth community 👋 — I’ve got a quick question (and possibly a suggestion) regarding how to properly use the SDK on the backend. I'm trying to update an organization from a Next.js API route, specifically from a webhook handler for Polar (a payment provider). I noticed there’s a auth.api.updateOrganization method available on the server-side auth object, but its usage is a bit unclear in a backend-only context. It seems to require headers like 'Content-Type': 'application/json', but since I'm not making an external API call (just referencing the SDK on the server), it feels a bit awkward. Here's what I currently have:...

getSession called in next middleware reports: PrismaClient is unable to run in this browser envir..

The full error message is : [Better Auth]: INTERNAL_SERVER_ERROR Error: PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in ``). Looks like better-auth is trying to call prisma in the next Edge environment which it shouldn't. Anybody seen that before ?...

Google OneTap when the app is on dark mode contains a white background

I'm using Next.js and Shadcn UI and Google OneTap, with better-auth. When the app is in light mode, the Google OneTap popup is white and looks fine but when the app is in dark mode it is automatically set to dark mode (that's fine) but there remains a white background around the popup. Can anyone help me out? I have no specific stylings for the popup.
No description

noobie question whats the better auth secret used for? is it just managing sessions?

cuz for security reasons i dont want to forever use the same key in my app so id ideally want to be able to rotate it every now and then, but then the other question, if its only used for sessions, would changing it force logout all users? if so, could i gradually do it over time and insert an array of old secret and new secret and slowly transition to the new one?...

How to insert timestamp in lastLogin for social login like google

```js const signInWithGoogle = async () => { try { await authClient.signIn.social({ provider: "google",...

Update/Fetch tables with custom fields

Hi! I’m using Better Auth in a multi-tenant SaaS app. I have a Member table, given by organisation plugin (separate from the core user table) that stores organization-specific fields for each user (like company email, designation, etc.). I noticed that Better Auth’s APIs (like getActiveMember) only return the fields it knows about, and do not include any custom fields I’ve added to my Member table. I want to be able to fetch and update these custom fields through Better Auth, or at least have a recommended way to do this. Is there any built-in way in Better Auth to fetch and update custom fields from custom tables (like Member), or do I have to create my own backend endpoints for this? ...

Getting a very strange issue with apple sign in using web client

✘ [ERROR] # SERVER_ERROR: TypeError: Key for the RS256 algorithm must be one of type CryptoKey, KeyObject, or JSON Web Key. Received an instance of CryptoKey
✘ [ERROR] # SERVER_ERROR: TypeError: Key for the RS256 algorithm must be one of type CryptoKey, KeyObject, or JSON Web Key. Received an instance of CryptoKey

Can't pass token_access_type to dropbox provider? No way to get refresh token?

Hi! Probably newbie err, but it appears that the dropbox social provider doesn't support setting token_access_type=offline, nor does it seem to honor authorizationURLParams in the options. Alas, together, these perhaps make it impossible to request a refresh_token? I've tried working around this by making my own dropbox provider using the genericOAuth base, but that has it's own problems (I think there's a problem with dropbox's pkce config which breaks using genericOAuth). So I'm kind of stuck 😦...

resetPassword & emailVerified

When resetPassword is successful, emailVerified should be turned to true also, no ?!

resetPassword & autoSignIn

I can see in the doc that autoSignIn is for "after sign up". But could we have a flag for autoSignInAfterResetPassword ?...

emailAndPassword sign-up error in Nodejs-Express

- The user was added to the DB, but the api responded with error [500]. - [Better Auth] ERROR The field "expiresAt" does not exist in the "account" schema. - Session was not created after sign-up The schema was generated with the CLI and No "expiresAt" on the account table....
No description

Using existing DB schema with Drizzle

I created a schema for the better auth table called better-auth which I'm passing as auth options to the drizzle adapter. However when I run the cli command to generate the schemas, the better-auth schema isn't being used. Is there a way to use the custom schema I created? The following is my authOptions which I'm sharing between the actual auth instance and a fake one which is used with the cli. ```ts export const authOptions: BetterAuthOptions = { database: drizzleAdapter(...

cookie cache additional fields

It doesn't appear that additionalFields in the betterauth config extend to cookie cache.

getCookieCache returns null?

So I am using NextJS, and have set everything up. For the most part BetterAuth works awesome. I want to use the getCookieCache method, so I enable cookie caching in my auth.ts. However, when I look at the docs, and implement the middleware check, my getCookieCache is always null, even when there is a session....

Inferring types on the server

Is it also possible to infer the return-types of specific API routes on the server? I am creating a better-auth wrapper using effect-ts for my application and am missing some type-safety on the server. ```ts...