Better Auth

BA

Better Auth

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

Join

bug-reports

help

Setting up additional fields in organization plugin.

I want to know how to set up additional fields in organization. Am using react vite as client and express.js as server. I want to know how to set it up and also update the organization with the fields added. What I tried always gives 500 error invalid parameters or something

session data is null despite session cookie

so i have a hono api and i've writtten a custom middlware to check for authentication which works fine locally however, in prod (deployed on cf workers) despite the headers containing the session cookie the session is null, here's my middleware: https://github.com/777advait/better-auth-monorepo/blob/main/apps/api/src/middlewares/authenticated.ts server logs: ``` GET https://better-api.astro-dev.tech/api/auth/me - Ok @ 7/27/2025, 11:07:06 PM...
Solution:
i fixed it! it was a cloudflare issue, i was instantiating an auth instance in my api app, and the base URL of that was a worker, workers dont allow communication among each other over public network, the requests fail silently (no messages no warnings), it can only be permitted via service bindings https://developers.cloudflare.com/workers/configuration/routing/custom-domains/#worker-to-worker-communication https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/ i just moved my auth stuff into the api app so there's no worker-worker communication, everything sits in one place, it'd be good to be able to define custom fetch functions when instantiating auth instances in future...

Completely different user flows

What would be the recommended approach for handling vastly different user types with better auth? I have, for example, students and teachers that have different requirements and sign up flows with many additional fields. Should I make two separate auth instances with their own db tables and routes or keep just one instance with roles and do table joins for other fields?...

auth/organization/list only lists 100 organizations -- is there a way to list all?

is there a way to list all organizations a user is a member of? it seems like by default there is a limit of 100

Multi-tenancy with drizzleAdapter

Hi everyone šŸ‘‹ I'm working on a multi-tenant application where the database (Postgres) is determined based on the current domain or subdomain. I've customized the migration workflow so I can apply the same migrations across multiple schemas or databases — that part is working fine. Now I'm facing an issue with the drizzleAdapter used in authentication. The current implementation connects to a fixed schema, but in my case, I need it to connect dynamically based on the current tenant....

Authclient SSR

I'm very confused, can you help me? I have a Hono backend application and I use nextjs for frontend purposes. I query the session in SSR with authClient.getSession. I solved the issue of the session not coming without adding headers to the fetchOptions section. However, when I publish it, the SSR session query that works locally stops working. What could be the potential cause?...

TypeScript Error: Extended Core Schema’s isAdmin Not Recognized on User

I’ve extended my Core schema to add an isAdmin: boolean flag to the User type and included the same ā€œmac and resolveā€ middleware in my app to enforce admin checks. The application runs perfectly and correctly verifies a user’s admin status at runtime, but TypeScript still complains that user.isAdmin does not exist on type User. Has anyone encountered this before? What am I missing in my type declarations or module augmentation to get TypeScript to recognize the new isAdmin property? Any help would be greatly appreciated—thanks!...
No description

How to persist next-intl locale during social-provider sign-up?

I can’t figure out how to reliably save the user’s locale during social-provider sign-up (Google, GitHub, etc.). My app uses next-intl, so the locale is always a path param (/en/…, /cs/…). With email+password I simply send locale in the body, but OAuth redirects lose this value. Current attempt Client (Next.js 15 + better-auth 1.3.2):...
Solution:
Solution: ``` if (ctx.path.startsWith("/callback/")) { //Here just use a /callback/ to catch all OAuth routes const newSession = ctx.context.newSession ?? ctx.context.session; if (newSession) {...

auth in distributed system

i wanted to build a distributed system with a standalone auth server that is used by both my hono api and nextjs frontend, since im using a monorepo my plan is to create a shared auth package with auth server and client instances, then create a separate hono server that uses the auth server instance for handling requests, and then the same auth client and server instances can be used in my api and frontend wanted to know if this is a good mental map or there would be some better apporaches to this...

403 User is not part of organization

I calling with authClient.useListOrganizations()all my organization but when I want to set one as active I get an 403 with message User is not a member of the organization. I checked in my db the users as well and he is part of organization. Do i miss something? my snippet: ```js...

Discord integration problems.

Hi, I’m having an issue with integrating Discord with Better-Auth. In my app, I have the following logic using authClient.linkSocial: ```ts const handleLinkDiscord = async () => { try {...
No description

Limits field in stripe plugin?

In the example in the docs there's a limits object with projects and storage. Those are the only options. What limits is it referring too?
No description

Verification table not populating

I am unsure what is happening at the moment but my emailVerification process works as intended except for it not populating a new row in the verification table. I'm not sure what would be causing this issue as I used the drizzle-kit to generate the schemas. ```js emailAndPassword: {...

How are built-in API endpoints / routes enabled?

According to the docs when using emailandpassword on the server one can use the endpoint /sign-up/email, https://www.better-auth.com/docs/authentication/email-password#sign-up. So when I Hono is set up, like in the bun-hono-better-auth project, https://github.com/ProMehedi/bun-hono-better-auth/blob/main/server/src/server.ts // Better-Auth - Handle all auth routes app.all('/api/auth/*', async (c) => { return await auth.handler(c.req.raw) })...

TanStack Query + Better-Auth

Do you guys use TanStack Query with Better Auth? I use it as my async manager for my own api calls. But was wondering if I should with better-auth authClient calls? Wrap it in TanStack Query? Cause I would use its cache invalidation for queries when mutations were done. Without it, idk how to handle authClient queries being fetched again on mutation....

Write custom plugin for telegram bot

Hey guys so i wanna support telegram plugin Dunno where to start from or how tg works I just have a simple bot and i wanna be able to login/signup using user chat id ...

Integrate Google login with 2FA

Hello everyone, I am currently working on a dashboard app of a company, and they want a more secure way to login when staff login their Google account, maybe face recognition or some ways else. And I wonder is it possible to use 2FA plugin with Google's OAuth login? I just check the docs and it seems to work with credential login Just want to know is it possible to acheive integration 2FA with Google OAuth login?...

Export disappeared

import { type UserWithRole } from 'better-auth/plugins';
import { type UserWithRole } from 'better-auth/plugins';
This export suddenly disappeared from the library, why did it get private?...
Solution:
I'm not sure why it got private, but I do think it's better practice to use the inferred User from your auth instance as that should include role if you're using the admin plugin

Custom error when user has a Google account but no credentials account.

Hey all! I have a small problem with my app. How can I show the user that they can't log in with email/password because they already created an account using Google? Thanks!...
Solution:
this could be achieved with db hooks https://www.better-auth.com/docs/concepts/hooks...