Better Auth

BA

Better Auth

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

Join

bug-reports

help

Org plugin is ignoring additional fields on teams

I added a slug property to my team schema, but its not being passed when i actually try and use it ```ts export const auth = betterAuth({...
No description

RBAC

i need someone xplain me why this not works ```ts import { createAccessControl } from "better-auth/plugins/access"; import { defaultStatements, adminAc } from "better-auth/plugins/admin/access";...
No description

Expo setup error

Hi, I get this error when I change my metro and babel config. I got it when I changed only metro config and when I added "babel-plugin-module-resolver" I still get it. My metro.config.js and babel.config.js:...
Solution:
I fixed it by removing this line from metro.config.js: config.resolver.unstable_enablePackageExports = true;...
No description

Astro + Drizzle + Cloudflare D1

Hello, Is there a way to properly setup Better Auth with Drizzle + D1 on Astro? Since the D1 DB is only accessible in the Astro context (in an .astro page or in a API Route), it is not possible to return an “auth” constant....

Keycloak SSO Integration

I'm trying to integrate betterAuth with Keycloak SSO to handle sign-in and token rotation, but I'm struggling with the configuration. I don't want to use a database in my Next.js frontend since Keycloak manages all user database tables and is integrated with the backend. The backend is already integrated with keycloak to verify JWT. ...

signout on the server

Suppose I am submitting a Form to the server and I want to sign out in the form handler. So I wanted to know how to properly sign out on the server. Is it enough to just call auth.api.signOut or should I mange the cookie headers too? Is there a section in documentation about server side session handling? please help.

TypeError: list.filter is not a function.

entire error: ``` SERVER_ERROR: 293 | ); 294 | let list = []; 295 | const now = Date.now();...

Adding Members to Organization with Teams Enabled

I am using the organization plugin with teams enabled and am trying to add members to the organization/team via the addMember API call: ```ts await auth.api.addMember({ body: {...

Is there a way to customize userCreate function to populate additional field?

In my usecase I need to copy user.id value to another column userId or id_email upon user creation

Admin + Organization Plugin: Role Columns

I have a question about using the admin and organization plugins together. When using the admin plugin, it adds a role column to the user table and when using the organization plugin, it creates a member table that itself contains a role column along with a userId column that references the earlier user table. The question I have is, how should the relationship between those two distinct role columns be managed? What are the expectations?...

User agent update

User agent is being set to "okhttp/4.9.2" when using the below Google Sign in method with an existing idToken in expo ```const data = await authClient.signIn.social({ provider: "google", idToken: { token: // Google ID Token,...

Error creating organization

SERVER_ERROR: [Error [BetterAuthError]: The field "slug" does not exist in the schema for the model "organization". Please update your schema.] { cause: undefined } ...
No description

Stripe. Annual subscription not updating in database

When i try creating an annual subscription. it does not update in database. I use Express.js in backend, and react in frontend

Get User by ID

I store the BetterAuth user ID in my app DB. I can list all users but not query them by just the ID.

How to implement Free tier in Stripe plugin?

Basically the title, in the docs i don't see any mention on how to handle free tier for users.

using redis as secondary storage for sessions

Hi in the better-auth example I saw import { betterAuth } from "better-auth"; import { redisStorage } from "better-auth/storage"; ...

authClient.admin.hasPermission always returns 401 unauthorized

Hey, i'm using the auth plugin, The api/auth/admin/has-permission endpoint always returns 401 even though i'm logged in. I have custom roles ```...

How to get a list of guilds a user is in on Discord using Better-Auth

Nice to meet you. This is my first time using Better-Auth. With OAuth authentication by Discord, I would like to obtain the guild information the user is participating in as well as the user information via the endpoint. However, the access token cannot be found in the information returned by the session, so it cannot be fetched to the endpoint. In next-auth, you can obtain these using callbacks, but how can you implement this in better-auth? I found an implementation example in next-auth, so I'd like to share it with you. https://github.com/nextauthjs/next-auth/discussions/3774 The environment I am using is Next.js v14.2.23, the latest version of Better-Auth, and MySQL connection via Prisma....

Adding custom user fields (role, address, etc.) to auth.api.getSession()

When I call: ```ts const session = await auth.api.getSession({ headers: await headers(),...

Set tables in auth not public

Is it possible to set an option for better-auth to create the tables under auth instead of public in postgresql?