Better Auth

BA

Better Auth

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

Join

bug-reports

help

Auto logout

Hi, Im using nextjs + mongodb and Redis for caching. But when I update the site, some users getting logged out. and some was saying that it takes a few minutes to login again....

Infer additional fields for admin?

Is admin not able to infer types for additional fields like so when the types come from a plugin? I have added the InferTypes on the client plugin. ``` await admin.createUser({ name, email,...

Expo - In-app browser not showing up

Hi, I'm using better-auth hosted on a next.js backend With Expo, I'm following the documentation and the login button (physical and simulator) is not doing anything (no redirect, browser, etc.) ```ts...

Express error

Hello, i have an error with express as my backend. When i press the login button, this error happens. I tried changing cors like 3 times but no luck. anyone got a clue?...
No description

Cannot read user data after social sign in with google

After a successful login using google I need to use the user id, the type of the response says that I can read that information but it isn't accessible and I don't know what to do. Does anyone know how to get it or solve it ?...
No description

Google Oauth Scopes Error

src/lib/auth.ts ```ts import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; import { prisma } from "./prisma";...
Solution:
you should pass scopes as an array of string instead
No description

Conflict between Admin and Anonymous plugins – 500 error

Hello, I'm having an issue with two plugins: Admin and Anonymous. When I try to use Anonymous while the Admin plugin is enabled, I get a 500 error. However, if I disable the Admin plugin, Anonymous works perfectly. ...
No description

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",...