Better Auth

BA

Better Auth

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

Join

bug-reports

help

how to map custom schema with better-auth

my drizzle tables eg: ``` export const Users = pgTable( "users",...

Admin List Users not returning Pagination data

Hi guys! I just recently updated my better auth to 1.2.4 because previously on 1.1.1 I was only able to get the list of users from the listUsers API. However, after upgrading I'm still not able to get the pagination information from this endpoint. Any idea why? ```const response = await authClient.admin.listUsers({ query: {...

inferAdditionalFields doesnt work?

Im trying to use authClient.signUp.email function on client side. But i cant see my Additional fields on client side. I can see them on server side. ```ts auth-client.ts ...

newbie: are my conventions for checking if a user is logged in on client and server side fine?

hi so this is my first time rolling my own auth. ive used clerk before. the db im using with better auth is mongodb as my user data is there rn. We only need google auth (no email/password). I've gone through the installation and setup and ive got google user logins registering in my mongodb collection. The question I have is, am I properly checking if the users logged in (client and server side)?...

Organization Member List get if two factor Auth is enabled

Hii, when I call authClient.useActiveOrganization() in SvelteKit, I'll get the Organization Data including a array with all members. I'd like to include the data if the member has two factor enabled, if his email is verified and if hes banned. Is there any way to do this besides making my own call to the database? Thank you! :)

Updating Discord Image

Hello, Is there a way with the Discord auth to update the image of the user everytime they sign in, or do we need to manually check if the image is still valid, and then update it if needed ?

Custom Fields

Hey! How can I do custom additional fields like Containers? Users can have containers which have a name and image.

JWKS Error

Hello, I set up the oidc provider and configured the sso plugin, but when I tried to log in with sso, this is exactly where I got stuck const key = keys.find((key) => key.kid === header.kid); ...
No description

Prisma + Better Auth + Turborepo Issue 🤔

Hey everyone! Here's what's happening: The Setup - Using a Turborepo with Next.js - Prisma schema is in a separate package (packages/database)...

Providing additional fields when signing up via magic link

Hey there, when I sign up via magic link from the client with the code below I'm not able to pass custom / additional user fields (i.e. firstName, lastName). Or do I miss anything? const { error } = await authClient.signIn.magicLink({ email: data.email, callbackURL: returnUrl,...

creating the first user, where disableSignUp is true

Hi, are there any suggestions on how to do this? I've created the DB schema fine but with this off and no API in place yet I was hoping there'd be a CLI command

Can not change the issuer and audience of JWT header and also the payload

So tried to change the issuer and the audience of my jwt config by following the documentation but it's not working as expected here it's my config ` 'plugins: [ jwt({ jwt: { issuer: env.BETTER_AUTH_URL, audience: env.REDIRECT_PROXY_URL,...

How to implement invite-only registration flow with better-auth?

Hello, I'm looking for some help on how to implement this use-case. Here is the general user creation/registration flow I want to implement:
1. Existing admin user adds a new user by entering their email (and possibly name and role). 2. The new user receives email with a welcome message and a link (time limited) to complete account setup. 3. After clicking the link, the user is redirected to a page where they can enter a password and/or link their social account....
Solution:
we'll have sendInvite functionality in the admin plugin soon but magic link or forgot password for the time being should work fine

How can I make better-auth typesafe?

I currently trying to make a list with all members and invitations, but I constanly running in typing errors.
No description

kysely + organization setup

Hi, I'm evaluating better-auth and it looks great! Are there any code examples of email + password & organization configured alongside using kyself to define other Tables etc? It feels as though organization and the other entities are under the umbrella of better-auth but I'd like a single layer to interact with DB stuff where I'd consider Organization to be DB

Question on authorization

Hey, I have a stupid question. However, I can't figure it out at the moment. When I make an api call (from my api with hono). The following always returns null: const session = await auth.api.getSession({ headers: c.req.raw.headers });...

2-step login flow and organization question

Hi! I am trying to implement a 2-step login flow where the user first inputs the email address, then depending on the email domain and if the user is already provisioned follow-up with the second step. My questions:...

Extending user object when calling getFullOrganization()

Hi everyone, I added an additional field (phoneNumber) to the User property. How can I include that additional field in the user object when calling getFullOrganization()? Does better-auth provide this feature, or do I need to create my own custom?
Solution:
yeah the org plugin doesn't support this currently.

MongoDB Error Duplicate key

I sometimes get this error when authenticating with MongoDB: ``` errorResponse: { apps/backend dev: index: 0,...

Running npx @better-auth/cli@latest generate does nothing.

I'm trying to set up my user schema and using drizzle and pg. When i run the command to create the migration file, it just installs the cli and nothing happens. Doesnt matter if i add flags or not. Has anyone experienced this?
No description