Better Auth

BA

Better Auth

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

Join

bug-reports

help

Question regarding callbacks (used by next auth)

On Next Auth lib there's the callback system that is called after a user is logged in. Is there something similar in better auth? I would like to do some work when user logs in/signs up.

I'm trying to disable some routes

I'm trying to disable some routes, I saw that there is a string array "disabledPaths". Mine is like this ```disabledPaths: [ '/change-email', '/list-sessions', '/list-accounts', '/unlink-account',...

Help handling JWT with Sveltekit

I am new to JWT but need them for a third-party API - what is the best practice to handle/cache them?

Custom Session running twice on GET /api/auth/get-session

I'm trying out custom session to return some additonal team fields on the repsonse to use on the client side and i noticed(sinces its making a call to the db and i have the logger on) it's running the custom Session method twice for every single call to GET /api/auth/get-session is this to be expected or have i done something funky in my config my custom session looks like the following: ```typescript customSession(async ({ user, session }) => { if (config.dev) console.log('custom session is running');...
Solution:
OK i had to do something funky i literaly had to copy over your customSessionClientPlugin and make this change ```typescript async (ctx) => { const session = await getSessionFromCtx(ctx);...

manual session refresh

Is there a way to refresh the existing session when we will the session freshAge?

Google redirect_uri_mismatch auth

my backend running on localhost:8000 front end running on localhost: 3000 here's my google redirect uri ...
No description

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)?...
Solution:
For guarding routes, use middleware to redirect users - but don’t fetch the session in the middleware, just rely on cookies (there’s an example in our Next.js integration docs). For protecting pages, fetch the session in an RSC component and decide what to render based on that. Regarding performance, make sure to use cookies in the middleware (without fetching the session), enable cookie cache, and make sure to proper DB indexes (explore optimization methods from the docs) https://www.better-auth.com/docs/guides/optimizing-for-performance...

Stripe Embedded Checkout

Are embedded checkout pages supported by the stripe plugin?

auth.api.getSession not refreshing session_data cookie

Hi, I am using better-auth with sveltekit. My auth.ts has session.cookieCache to true and maxAge of 1 second for testing purposes. ...
Solution:
the issue is when you use api.getSession it can't set the cookie in your browser unless you do it manually

Better auth organization

Please how implement organization pluging of better auth to system de school management where all model on db point to school table in this case organization. And can add some attributs manually on models ? I'm not english natif so.

Seeding an admin user

I want to seed an admin user in my Express app. export const auth = betterAuth({ appName: 'LaundryApp', basePath: '/api/auth',...

How to get type for permissions

I'm using the organisation plugin and i have created some custom roles. On the client I have a sidebar where some items are gated depending on the role of the member. So i don't have to go back to the server multiple times, im calling getActiveMember in my layout and passing the role of the active member into the sidebar and then making use of authClient.organization.checkRolePermission. I'd like to specify in a central location all my sidebar items and groups and what permissions are needed to access the page. ...

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