Better Auth

BA

Better Auth

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

Join

bug-reports

help

callbackURL doesnt work with signUp

```ts await authClient.signUp.email({ name: values.name, email: values.email, password: values.password,...

Module' "better-auth" 'has no exported member 'betterAuth' .

So I upgraded to latest version "better-auth": "^1.3.8", and my site wont build...
No description

Remember me for signin.emailOtp

Loving this library but Im stuck trying to setup remember me. It seems to be in signin.email() but not signin.emailOtp(). I attempted to use a before hook middleware to make the login session but couldn't figure it out. How should I go about setting this up?...
Solution:
```ts // Frontend authClient.signIn.emailOtp( { otp: code,...

How to refetch user data client-side?

I'm updating the user object on the server-side and need to trigger an update from the client side. Is there a function, I can call from the client to refetch the session from the server?
Solution:
Yeah getSession will always hit your server, but if you have session-cookie-cache then it won't hit your DB

Please Help: I am having a callback url issue.

My backend is running on port 8080 using fastify, while frontend is nextjs running on 3000. On the google developer console i have setup up the callback uri as follows http://localhost:3000/auth/google/callback ...

how to use odic plugin in a monorepo setup

Hello, i idealy want a auth.company.com to handle odic, and then have stuff like account.company.com, product.company.com, product.com use the same auth, i can see how to setup the odic server in better auth, but then how to use better auth in the other ones to login with it

React native node:buffer

The package at "node_modules/jose/dist/node/esm/runtime/base64url.js" attempted to import the Node standard library module "node:buffer". exacly similar issue as https://github.com/better-auth/better-auth/issues/1551 better-auth version 1.3.8...

RavenDB adapter

I have built my own adapter for RavenDB. Raven is a document database and when I use the organization plugin I get JSON as a string in the metadata. Is it possible to make better auth not to serialize the metadata field as a string? Is this metadata needed for the organization plugin to work? This is how the document look like in RavenDB. ```{ "name": "Marcus plats", "slug": "marcus-plats", "logo": "🏢",...

Uncaught SyntaxError: 'super' keyword unexpected here. better-auth_client_plugins.js:11633

please someone help I am getting this error in the latest version of better-auth I am using react router v7 in frontend and hono in backend I both deploy to cloudflare workers I am getting this error on both localhost and on cloudflare workers...
No description

node:sqlite

Hi everyone, I'm facing this error when trying to use Vite with Better Auth: [vite] (ood_saas) warning: Automatically externalized node built-in module "node:sqlite" imported from "node_modules/.pnpm/better-auth@1.3.8_react-dom@19.0.0_react@19.0.0__react@19.0.0/node_modules/better-auth/dist/shared/better-auth.B8b3lep0.mjs". Consider adding it to environments.ood_saas.external if it is intended. but I'm not even using sqlite, I'm using postgres with drizzle, with Hono and cloudflare workers....

oAuthProtectedResourceMetadata is not exported from plugins

The documentation here states that you need to expose a route to send the oAuthProtectedResourceMetadata which makes sense but: 1. the route file is wrong (name of the file is .well-known/oauth-authorization-server/route.ts which is to expose the oauth autorization server rather than the metadata 2. the utility is not actually exported from better-auth/plugins ...

user session null

Hi all, I searched and saw a few posts related to my problem but the solution was not enough so I decided to make my own post. I am trying out Better-Auth with Prisma. Problem: I don't see user session after signing up or logging in. I am able to see the db populate with the information + session data. What I'm trying to do:...

How to make discord provider save username also in prisma adabter?

How to make discord provider save username also in prisma adabter? Pls i need answer

Setup for cross domains and local "cross ips" development?

Hey all! I have migrated my "supabase everything backend" to a hono+better-auth backend and I couldn't be happier! I have tried NextAuth/AuthJS and Lucia before but they all felt unreliable and poorly implemented. Better-auth as young as it is the best js auth solution I've ever used! The only problem I'm having is with cross domain auth... I have 2 situations that are not working: - Local development with cross ip: I run my backend and frontend on my computer and try to open my frontend on my phone through a local ip like "192.168.22.168:8081". - I have deploy previews configured on cloudflare pages, so when I open a PR it creates a preview url like branch-name.my-app.pages.dev (this is a cloudflare subdomain not on my custom domain, so its a cross-domain)...

How can I manage user roles when the client and server are in different projects?

Hello Better Auth community, I have a question that my team and I are currently grappling with regarding how to manage roles when you have separate environments. The documentation on roles mentions that: “You also need to pass the access controller and the roles to the client plugin.” That means that this library assumes that you are working in a monorepo environment or, if not, in a full-stack environment. I understand that it is not ideal to have a permissions.ts in each project, because if one changes, the other also has to change. Is this where a solution such as microservices or a shared library might come in?...
Solution:
We will have database support soon, PR is merged and in canary now (https://github.com/better-auth/better-auth/pull/4087) besides that another solution could be to use git sub-modules, although it's still not the most ideal solution. it's hard to solve when you don't have direct access between the projects, some system has to be in place to keep them in sync

Username plugin with drizzle adapter gives Types errors

I was setting up a very simple better auth example with express (i know i know, but I'm doing an experiment 😄 ) but even before setting up anything I have this very weird type error when using the username plugin with the drizzle adapter. ```ts import { betterAuth } from 'better-auth'; import { drizzleAdapter } from 'better-auth/adapters/drizzle';...

Enable 2FA by default for all users

Is there a way to enable 2FA by default for all users who sign up to my app? @Better Auth

Auth object necessary in NextJS? but my backend is on another server.

I have a quick question ``` import { auth } from "@/lib/auth"; import { headers } from "next/headers";...

sendVerificationEmail bug?

What will happen if run sendVerificationEmail to email that not registered? because i already tried and it return success...

Is there a way to send both Magic Link and OTP together in one email?

During signin/signup I want to send users both Magic link and OTP in one email and user can choose to either login with magic link or enter OTP. Currently we have two separate plugins to send magic link and email OTP. Are there any known workarounds to combine them?...