Better Auth

BA

Better Auth

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

Join

bug-reports

help

Dynamic Access Control help

This is the payload am sending organizationId: "FuU76BR0cBqTIK263o8GQUKqwZVPdu7f" permission: {product: ["view"], user: ["share"], order: [], marketing: ["share"], analytics: []} analytics: [] marketing: ["share"]...

JWT plugin with sessions instead of Refresh Tokens

In my React Native Expo app, after Apple Sign-In I need to access my own API. I’m considering implementing the JWT plugin. What do you think? Up until now, I haven’t been using sessions at all — I had been running everything with only JWT (Access Tokens and Refresh Tokens ) . That’s why this “session × short-lived JWT” approach feels a bit concerning since it doesn’t involve a Refresh Token....

How to customize OneTap CSS (Position)?

In OneTap Documentation, it has a field to customize the position using css. But there is no field for me to do in better auth OneTap plugin.

Prevent full page reload on SPA when signUp

Hi everyone, when using the authClient.signUp.email I get a full-page reload (SPA Vite, React, Tanstack Router) which affects the UX. I just want to be able to manage the result locally.

Cloudflare Error: "The Workers runtime canceled this request" when redirecting to Callback api

When Authenticating user with github, I got cloudflare error when redirecting to callback url ../api/auth/callback/github?code=xxxx&state=xxxx The error says in the log: The Workers runtime canceled this request because it detected that your Worker's code had hung and would never generate a response. Refer to: https://developers.cloudflare.com/workers/observability/errors/ ...
No description

routes return null

I'm using better-auth with fastify and all my auth routes are returning only "null" on the body. i'm kinda lost here trying to debug the reason. (yeah tried ask llms but even them can't help much) // auth.ts ```ts import { betterAuth } from "better-auth"; import { drizzleAdapter } from "better-auth/adapters/drizzle";...

ipaddress and useragent missing from sessions

```ts
advanced: { ipAddress: { ipAddressHeaders: ['cf-connecting-ip', 'cf-connecting-ipv6'], },...

Modify field types like using in for User Ids?

Is it possible to modify the way better auth creates users? I have a system i am looking to migrate that currently uses ints for userIds. is it possibler to get betterAuth to replicate this behaviour? or do i need to convert all int ids to string uuids?

Email OTP with Username plugin

I have setup username plugin alongside Email OTP plugin. All good but I have a doubt. How can the user while signing up with email otp have thier username setup automatically?
I did create a custom plugin to solve this issue. The plugin hooks after the email otp sign in and updates the username in db. Only problem is the session does not reflect the updated username. Is this the preferred way to set username automatically? or is there a better way to do this?...

Do I need crossSubDomainCookies?

Hello, everyone, so I'm building my application as following: - frontend: app.mydomain.com - backend: api.mydomain.com should I use crossSubDomainCookies? or should I just keep it as is? And also, How can I set this up in development? Here is my current setup:...

Auto sign-in after OTP email verification?

Hey all. I'm trying to implement email verification through OTP in my app but I ran into this UX issue where the user signs in, has to verify their email through OTP, then they have to sign in again. My question is, is it possible to have an auto-sign in after OTP email verification similar to how the email link verification has the autoSignInAfterVerification? Thank you in advance!...

JSON parse error with oidcProvider and oidcClient()?

I'm encountering a weird error. I have two services, a vite/hono app serving as the oidc provider, and then a nextjs app serving as a client. Whenever I open up the vite/hono app and sign in to the oauth service, and then try to use the sign in button on the nextjs app, I encounter this error. ```[0] # SERVER_ERROR: 955 | throw new APIError("UNAUTHORIZED", { [0] 956 | error_description: "client is disabled", [0] 957 | error: "invalid_client"...

anonymous passkey

Hey all! I was wondering - Is it also possible to offer anonymous passkey auth? E.g. by combining anonymous and passkey auth? the passkey authentication docs say passing an email address is required......

I want to create a subscription with free trial with stripe

Do I need to use the better-auth stripe plugin for this or the stripe sdk? It seems that when I do: const subscription = await auth.api.upgradeSubscription({ body: { plan: "Starter Monthly",...

How to silently refresh session (triggering the session.before.create hooks)

When a user logs in, I check if they belong to any orgs, and set the activeOrganizationId in session.before.create, if they do. I also add member_id and member_role to the session, for quick access. But when they change active org, the hook doesn't seem to rerun. The activeorganizationId changes, but the other fields I've added don't. Can I manually create and set a new session silently, given that the user is already authenticated...
Solution:
You're looking to use update hook instead in this case

Set "locale" on Stripe Checkout

Does Better Auth support setting the locale on Stripe Checkout? If yes, could you guide me on how to implement it? Thanks!...
Solution:
I found a way to set locale for checkout page.

Magic Link on Expo

I'm having trouble making it work and had a look at the expo plugin implementation. It tries to parse the cookie from the onSuccess hook but that hook fires when the email is sent not after verification. So the plugin actually doesn't receive session token - it just calls the callback URL. Am I missing something? ```ts const { signIn } = createAuthClient({ baseURL: process.env.EXPO_PUBLIC_BETTER_AUTH_URL,...

Is this Valid way to fetch session? in SSR

I have setup my auth in a separate hono server and from my frontend (sveltekit) i want to get the session server side so that I can protect routes. I have access to authClient but not the auth instance because all auth logic is handled by the separate backend. The way im doing this is working im just wondering if this approach is correct or maybe theres a better way to solve this?...
No description

signInMagicLink with extended schema

Hello, i'm trying to create an new user and login it using magic link, but the problem is i have an additional field in the user table to specify the "type" of the user, how should i do that? Currently, when i click the magic link, i get an error "SQLITE_CONSTRAINT_NOTNULL" because of the prop "type" that is missing.
No description

Vercel deployment doesn't work anymore with 1.3.8 version

node:sqlite Module build failed: UnhandledSchemeError: Reading from "node:sqlite" is not handled by plugins (Unhandled scheme). Webpack supports "data:" and "file:" URIs by default. You may need an additional plugin to handle "node:" URIs. ...