Better Auth

BA

Better Auth

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

Join

bug-reports

help

Setup Help

I'm setting a turbo repo which has two apps admin and app both of them are next js. Should I also create an app called server which is a single auth instance with admin-user plugins and also organisation plugin or do the admin and app should have their own auth instance in the api folder. If I go with the server I will also be adding trpc which then will have adminProcedures (admin user) and protectedProductures(normal user). Please provide a better way to kickoff the project....

How to view 2FA backup codes

Hey everyone! I'm trying to use this method from the 2FA feature of better-auth: ```ts const data = await auth.api.viewBackupCodes({ body: {...

RSC cookie cache

Hey guys, In the context of a nextjs app, I'm wondering how to handle this:
As RSCs cannot set cookies, the cookie cache will not be refreshed until the server is interacted with from the client via Server Actions or Route Handlers....

expo-authorization-proxy not found

Hello, I've been using better-auth on native for a while, but my latest builds seem to try to access expo-authorization-proxy which is not available on my server, is this a breaking feature that wasn't documented?...

[oidcProvider] trustedClients don't get added to the OauthApplication table in the database.

I have set up two Next.js apps, both with better-auth. One serves as an oidc provider (https://idapp.appname.local), with the oidcProvider plugin installed. The other serves as a consumer of the oidc provider (https://clientapp.appname.local), with the generic oAuth plugin installed....

How to set username for user , while login with Google?

While login with credentials , user has options to set username , but when user choose to login with google , there is no username provided in session so how to set a username and save in DB , if user choose to login with google ??...

Prevent password login when social account linked

@Better Auth I'm currently have two login methods: Discord & Username/Password. I now want to block users from logging in with their password when they have a discord account linked. How woul'd I do that?

Support customizing generateOtp for phone numbers (similar to emailOtp plugin)

Currently, the generateOtp function seems customizable only in terms of length. For staging environments or certain phone numbers, it would be useful to generate a fixed OTP. The emailOtp plugin already supports this kind of customization, but there doesn’t appear to be an equivalent option for phone numbers.

/api/auth/get-session => 404

When I try to get session on the client-side with auth-client, I get 404. Before certain moment everything works well. Database connected....
No description

Specifying PostgreSQL Schema

With using Kysely and PostgreSQL with better-auth, is there a way to explicitly set the schema for the tables to be created on. I've tried this, ```ts const pool = new Pool({...

Disabling redirect email.signin if callbackURL set to null

I'm integrating better-auth into my pwa spa vite react app any tips on how to disabled redirect on email.signin default behavior is to redirect to root route (I can easily change redirect location using the callbackURL option in email.signin func, default value "/" root route, can't set it to null either ) causing a full page reload (which takes time) kinda defeats the purpose of using a spa to build, I want to handle redirects with my tan-stack router (doesn't reload the whole page)

Can't get better-auth working with the Tanstack Start and Convex stack

The weird part is the error gives me to nothing to work with, just fetch failed and even weirder is that it wouldn't happen on every reload, but when the page does reload, client interactivity wouldn't work, meaning no onClick handler stuff is working. Neither server nor browser console tells me anything. Have followed, checked and rechecked the setup process. https://convex-better-auth.netlify.app/framework-guides/tanstack-start...
No description

Pass custom extra fields on OAuth from client

When using signIn.social({ ... }) how can we pass extra data to be included on the user creation? For example, we want to pass a custom locale and pricing fields here. Any ideas on how to do this?

Using Generic OAuth Plugin to connect to Follow Up Boss

@Better Auth i’m trying to use the Generic OAuth plugin to enable an oauth link flow with followupboss. i have the following config: ``` genericOAuth({ config: [ {...

How i can use betterAuth.api.hasPermission in the backend if i don't have the headers of the user?

I have to check if a user has permissons in the backend, so is trusted but i don't have the headers because is a background job. how i can check the permissons without a header?

Sign in with (other applications better-auth) for this better-auth

This is a bit hard to understand but here we go: Application A: Better-Auth is setup, I have google and Github as OAuth providers on this. ...

Return data in my plugin

Hello, I would like my plugin to add additional information about the email to the request data, including types, and for it to be accessible on the server side from the request, but I don't know how to do it. Does anyone know? ```ts export const dymoEmailPlugin = ({ apiKey, emailRules }: DymoEmailPluginOptions) => { const defaultRules: EmailValidatorRules = { deny: ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"] as NegativeEmailRules[]...

better-auth-ui & Tanstack Start query issue

@daveycodez I'm trying to setup better-auth-ui with tanstack start and tanstack query. I followed exactly whats on the docs and the issue is when i log in and it re-directs me to "/" which i set in the redirectTo="/" of AuthView, using the tanstack query devtools the ["session"] data is always null. if i have the redirectTo="/dashboard" set, then it does have the data. So something to do with the home page that it resets the data to null. any idea? Thank you...

Redundant KV Keys

i'm noticing several redundant keys being made when using secondary storage (attached) here's my secondaryStorage from auth.ts ```ts // ......
No description

Tracking Active Users

Hi, I was trying to figure out the best way to track my active users. It seems like there's a couple of ways I could do it but they don't necessarily seem convenient. Here's a list of the options I have considered: - I was wondering if sessions would be modified in one way or another changing the updated_at value in the sessions table at least once a day so long as the fresh age was one day. - Considering going off of the getSession and point but that of course fires constantly since it's used pretty frequently across the web application as it stands right now (which it probably shouldn't be but oh well) - Considered using the lastLoginMethod plugin but discovered it does much the same thing as get session where it fires about 6-8 times. - Hooking sign-in endpoints is helpful for tracking sign-ins but they don't give me visiblity on "activity" ...