Better Auth

BA

Better Auth

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

Join

bug-reports

help

Migrating from nextauth/auth.js to better-auth

I'm currently in the process of migrating from auth.js to better-auth and have been following the guide here: https://www.better-auth.com/docs/guides/next-auth-migration-guide I've been able to map or create the new columns per the guide (within schema.prisma), but now when I try to log in with Google I get the following error: ``` SERVER_ERROR: [Error [PrismaClientValidationError]: ...

requestPasswordReset

Hi guys is requestPasswordReset deprecated? getting this error
│ ├╴ Property 'requestPasswordReset' does not exist on type '{ twoFactor: { enable: <FetchOptions extends { method?: string | undefined; headers?: (HeadersInit & (HeadersInit | CommonHeaders)) | undefined; cache?: RequestCache | undefined; ... 32 more ...; disableValidation?: boolean | undefined; }>(data_0: Prettify<...>, data_1?: FetchOptions | undefined) => Promise<...>; };...'. ts (2339) [27, 46]
│ ├╴ Property 'requestPasswordReset' does not exist on type '{ twoFactor: { enable: <FetchOptions extends { method?: string | undefined; headers?: (HeadersInit & (HeadersInit | CommonHeaders)) | undefined; cache?: RequestCache | undefined; ... 32 more ...; disableValidation?: boolean | undefined; }>(data_0: Prettify<...>, data_1?: FetchOptions | undefined) => Promise<...>; };...'. ts (2339) [27, 46]
...

better-auth (better-call) not found error can not be handle by elysiajs

the not found error: ```ts 2025-06-08T08:19:20.565Z ERROR [Better Auth]: Error 4816 | continue; 4817 | } 4818 | if (endpoint.options?.metadata?.SERVER_ONLY) continue;...

ip address can't set database

```ts import { db } from "@/db"; import * as schema from "@/db/schema"; import { betterAuth } from "better-auth"; import { drizzleAdapter } from "better-auth/adapters/drizzle";...
No description

How do i use createAuthCookie outside of better auth context?

If i create a plugin i have the following available to me in the plugin: ctx.context.createAuthCookie("session_token") How would I get access to this createAuthCookie in my own controller? ...

How can I change the interval of a user's active plan?

Let's say a user first buys a subscription with a monthly interval. They now decide that they want to pay yearly, since that one has a discount. How can I change that user's subscription interval from monthly to yearly? Is there a function provided by BA, or do I have to do this manually with stripe's sdk?

Magic link sign up with custom user parameters

I have two sign in forms one for basic users and another for admins. I store the role in a column on the users table. I'm using magic links for sign in. How can I pass the role to the user account creation? It seems there's no way to pass custom fields for user creation.

Offline first support

I there, does Better Auth have support for offline session mgmt? (im using react + express with oauth). It seems like the client.getSession() always sends a request to the backend and doesn't use a cached result. What's the recommended approach for offline? Would you simply cache the expiresAt field? (in addition to relevant session data)?...

How do i set values when using internalAdapter.createSession("uid", ctx);

I am creating sessions manually through a custom plugin for cases where I have guest users. I want to use the following method: const session = await ctx.context.internalAdapter.createSession(user_id, ctx); ...

rateLimit using database isn't working

I'm trying to setup rateLimit with database. After generating the schema & pushing to the database, I try signing in/changing password in the client a lot (That should trigger rateLimit) but it doesn't work for some reason. Here is my options.rateLimit: ```ts rateLimit: { enabled: true,...

extend account schema

It is possible to extend the accounts schema? I need to add a flag that indicates whether the account is active or not

`ctx.context.db` not available?

Why is ctx.context.db coming back as non existent? I'm using the drizzle adapter but I would like to use the kysley stuff inside the plugin so it doesn't end up only supporting drizzle. However ```ts gatherAttributes: createAuthEndpoint( "/abac/gatherAttributes", { method: "POST",...
Solution:
Appears it was removed in this PR https://github.com/better-auth/better-auth/pull/536 @bekacru Not sure if this was intended, if need be I'll make a PR to change the docs so db doesn't appear there anymore.

Why verifications table still empty when sign up?

this is my auth config ```ts export const auth = betterAuth({ database: drizzleAdapter(db, {...

Allow to disable the accountLinking

Hello 🙂 I'm trying to disabled the accountLinking : i would like one user with one account (for ex github and gitlab with same email => 2 users). For this, i've add this config : ```...

Checking before login and signup

Are there any ways to add a restriction for login and sign up? Like check if user table has same email with is_banned: true.

Anonymous plugin's isAnonymous field missing from the cached session

Hello, I have an issue with the anonymous plugin. The problem is when I log in with: await authClient.signIn.anonymous() ...
No description

Does anyone already used the phone number plugin ?

Hi, I’d like to use the Phone Number plugin, but I don’t see how I could handle sending SMS messages from my app. Does anyone have any ideas?

How to refresh session after changing org in Nuxt?

Using the following
const { data: session } = await $auth.useSession(useAuthFetch)
$auth.organization.setActive({ organizationId: org })
const { data: session } = await $auth.useSession(useAuthFetch)
$auth.organization.setActive({ organizationId: org })
...

How to redirect to `/sign-in` on all urls if unauthenticated

Hey there! I’d like to redirect unauthenticated users to /sign-in if they visit any url (except /sign-up). I see on the dashboard example...