Better Auth

BA

Better Auth

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

Join

bug-reports

help

What happens if the session freshness check fails ?

What happens if the session freshness check fails ? How do I prompt the user to refresh their session ?

Property 'stripeCustomerId' does not exist

Version: ^1.3.7-beta.4 I've loaded better-auth and @better-auth/stripe but keep getting this issue, not sure why... ``` src/integrations/trpc/routers/user.ts:23:23 - error TS2339: Property 'stripeCustomerId' does not exist on type '{ id: string; email: string; emailVerified: boolean; name: string; createdAt: Date; updatedAt: Date; image?: string | null | undefined; isAnonymous?: boolean | null | undefined; banned: boolean | ... 1 more ... | undefined; role?: string | ... 1 more ... | undefined; banReason?: string | ... 1 more ... | undefined; ...'....

Repetead API post calls

I'm having a problem with the admin plugin. I check userHasPermission in a client component view selector. I keep getting this repeated post requests. POST /api/auth/admin/has-permission 200 in 179ms 100+ of these lines and its not stopping,...

Anonymous User Per IP

How can I force that anonymous users are identified by their IPs such that any two users who log in with same IP use the same anonymous user?

Federated Logout

Hi, how do I sign-out of my OAuth Provider after calling authClient.signOut() ? I know signOut deletes cookies and invalidates session in DB, but I want to logout of my provider.

Using better-auth for a "custom"/none oauth2 sysem.

I'm trying to login with Plex, I would use "Credentials Provider" in Next Auth but unsure the best way to approach this with better-auth. Any ideas? Plex Auth guidelines; https://forums.plex.tv/t/authenticating-with-plex/609370 Code using NextAuth; https://github.com/RaunoT/plex-rewind/blob/develop/src/lib/auth.ts...

Question about global roles (super-admin) vs organization roles

I’m trying to set up two levels of roles in my app: Global role (super-admin): full access across all orgs Org roles (owner/admin/member): scoped to one organization...

Persist last active organization

I want to save the last active organization to automatically apply it to a new user session. I got the second part, but I'm unsure on how to save it in my database. I've tried the following, ```typescript hooks: {...

"Provider account provider is credential but it is not configured"

When I query my /account-info endpoint, I get a "PROVIDER_ACCOUNT_PROVIDER_IS_CREDENTIAL_BUT_IT_IS_NOT_CONFIGURED" error I'm not sure what is not configured since I can log in and out of the (credential) acc without issue....

Google access token not being updated after re linking with extra scopes

When users need additional Google scopes after initial login (e.g., adding Photos access after signing in with just email/profile), does the access token auto-update in the database after re-linking, or requires manual handling? Currently not seeing it update.

why organizations methods not working when I created it using drizzle-seeds

Actually I'm creating a organization with fake informations in my local. But, when I created it using drizzle-seed and try to insert a new member using auth.api.addMember, I receive a error message "NOT FOUND". ``` await seed(db, { organization: schema.organization }).refine((f) => ({ organization: {...

How to extend User Prisma model with Custom 1to1 relations when used @better-auth/cli

Hi there. Could you help please with subject? How I can add custom additional field as 1 to 1 relation? ```model User {...

Issues getting a backend signup request to work.

I am trying to convert my better-auth from using client side signup to instead use an api endpoint. The data seems to be passing through correctly but I have an issue with better-auth not reading the username.
Cannot read properties of undefined (reading 'username')
Cannot read properties of undefined (reading 'username')
...

Error: column "displayUsername" of relation "users" does not exist in better-auth 1.3.6

- I am getting the following error when I try to update a username in better-auth from a sveltekit client ``` SERVER_ERROR: error: column "displayUsername" of relation "users" does not exist at /Users/vr/Desktop/code/ch_NEXT/ch_api/node_modules/pg/lib/client.js:545:17...

Is Better-SQLITE3 necessary ?

Hello, I’m using Better Auth with Bun, Hono, and Prisma (Postgres), and I’m having an issue when building my app in the bun:alpine image. I either have to: - download a lot of packages for SQLite3 just to build (which takes more than 30 seconds), or - skip downloading the dependencies, in which case the SQLite postinstall fails. Is it possible to avoid downloading this dependency?...

Hono Handler Not Triggering

I cannot get my hono handler to trigger right, even with app.all, or app.on. It always gives me a 404. Here is my main code: ``` import 'dotenv/config'; import { env } from './utils/env.js'; import { serve } from '@hono/node-server';...

React SPA redirects on signIn and signUp

In a React SPA when I call authClient.signIn.email({email, password} my whole page does a hard reload on success. Is this intended behavior? I couldn't find the source code where this happens (yes, im preventing default in my form). Also, when I do authClient.signUp.email({name, email, password}, {onSuccess: () => navigate({ to: "/" })}) my auth check with authClient.getSession() in my protected route always fails and I end up redirected in my sign in form. How do you guys solve this race condition?...

how to correctly type useSession on the client side

I'm using React and using the useSession hook that comes from authClient, the data type comes as const data: { user: any; session: any; } | null. I saw the correct values in the console. How can I correctly type the user and session? This is my first time doing this setup...
No description

Help Implementing Captcha Plugin

I was making a project using the captcha plugin and was using the cloudflare turnstile for it but can't find much docs on it on how to implement the plugin. Is there any example repo with turnstile + better-auth just a request to also add that in the docs, I could do that also but not able to find an example ...

Keep active organisation stored between refresh.

Hi guys, I noticed that when the user signs in, the active organisation is set to null, as per the documentation. Is there a way to bypass this? So that once a user creates an org, or signs in, it automatically sets their last used organisation to their active one? Not sure if this is achievable from the config, and if not, what would you guys suggest I do? Thanks...