Better Auth

BA

Better Auth

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

Join

bug-reports

help

Internal Server Error when deployed to AWS

My Nextjs app works locally and when deployed to Vercel, however when I deploy to AWS via SST I am getting 500 internal server error for anything auth related. Is there anything special I have to do to get better auth to work in AWS Lamgda?

pass discord ID to session

I am trying to pass a users Discord ID through to the user object in session. I am aware of mapProfileToUser but not of how to use it to accomplish adding it to the session. I know how to add it custom fields to the session, just not how to get the profile object from socialProviders: { discord to custom session...

Organization inviteMember - Not Allowed to Invite

I keep getting a 403 - "YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION" This is a client component. User fills in the form to invite ```...
Solution:
Ok the solution is that you have to very carefully read the docs and not vibe code, lol. You have to use the default statements or the invitations feature will not work. So for example: ``` const statement = { ...defaultStatements,...

How to integrate BetterAuth with SolidJS

I'm using SolidJS for the frontend and Rocket (Rust) for the backend. I’m considering integrating BetterAuth, into my infrastructure. What would be the best approach to achieve this? Are there different ways to integrate it effectively?...

authClient.useSession() not callable in my Nextjs (15.2) client component

Hello. I use nextjs 15.2 and better-auth 1.2.4 I défined auth client like that:...

Using mongodb adapter and generateId creates id field in addition to _id field

using this config: ```ts import { createId } from '@paralleldrive/cuid2' const auth = betterAuth({...

authClient.listSessions returns empty array

Hey everyone, I'm trying to list the sessions of the user to display in their profile, but authClient.listSessions always returns an empty string. What am I missing? backend (hono js): ```export const auth = betterAuth({ emailAndPassword: {...
Solution:
@bekacru I forgot to post it here, but it has been solved, user error 🙂 https://github.com/better-auth/better-auth/issues/1965...

The organization plugin only a select number of server versions of the sdk?

Hello, I'm new here so sorry if I do something incorrectly 🙂 I'm coming from auth.js to better-auth and I really like the library so thanks for making it! Now my question(s). Is it true that some endpoints for the organization plugin are only made for the client version of the SDK? Like for example: update and delete organization?...

Does better auth support authenticating on subdomain, carrying over to main domain/other submains?

Hello, the current provider I use for auth doesn't support the option for the user to authenticate on i.e login.example.com, and then have the session in other subdomains such as test.example.com or even example.com. Does better auth have an option for this? I see in the docs it allows for subdoamins to get the session if authenticated on the main domain i.e example.com, but does it work the other way around too?

PrismaClientValidationError

Invalid prisma.session.update() invocation I am utilizing the latest version of BetterAuth and using the prisma adaptor from better-auth/adaptors/prisma and my db is postgresql. I am able to sign up and sign in just fine. However, when the current session needs to be updated, I get the following error. It appears it is trying to use the token for the lookup, but the error seems to indicate the call should be using id instead. My session schema is like this: ```prisma...
No description

Stripe migration does not work

I am using a postgres and drizzle for my project, I just added the better-auth/stripe plugin to my project. When I try to make a mirgration it shows that there are no changes, how can I trigger the migration other wise?

Wierd behaviour, isPending from useSession not triggering

const { data, isPending } = authClient.useSession();
console.log(isPending)

const { data, isPending } = authClient.useSession();
console.log(isPending)

Im using nextJS 15.2...

Custom Admin Role - Admin Plugin

I am trying to add an additional Admin Role to the Admin Plugin. I believe I have it set up according to the docs, but when I try to for example run authClient.admin.listUsers with my custom role, I receive the YOU_ARE_NOT_ALLOWED_TO_LIST_USERS Error. If I switch that user's role back to the default of 'admin' everything works as expected. I added screenshots of auth.ts, permissions.ts, and the function used to list users. Anyone have an idea on what I am doing wrong when creating a custom role?...
No description

Property 'surname' does not exist on type ...

I added custom surname field to user, added it inside additional fields in config but when using {session.user.surname} i get the error above even though surname clearly exists and is correctly displayed on the page

Server side Stripe usage

Hi, I'm focusing to use better-auth mostly (only) on the server, my client code is not aware of better-auth. My stack is deno + hono + htmx. So for it goes well. Hono route gets form data, calls auth.apisignInEmail and handles the response from that. Works good, I like that approach. Now I need to setup payments. Docs says I need auth client. IS there a way to deal with that only o nserver side? Of course I understand I will need some Stripe clienta at some point to show checkout ui, but I wonder how far I can get with my server-only apporach?...

Kinde to Better-Auth

Hello, since the development of this library has impressed me a lot, I want to switch to it, but there is such a problem. In the integration I established with kinde auth before, user ids were kept as autoincrement int in my own database, how can I transfer the data here now?

Custom Auth to Better Auth

I want to convert my custom auth apis into better auth. The problem is that I couldn't understand how to have more than two roles user and admin in better auth. It is an ecommerce web with user/vendor/admin roles, with varying profile information based on those roles.

Server email OTP authentication

It appears, from reading the docs, that email-and-password can be done if you're doing server-side auth only, however email-OTP is not currently supported. Am I missing something? I've got it working by having the server use the client library, but that's kind of ugly. Thanks!

ctx.redirect not working?

When the user is signing in, I want to check for something in the additional fields and redirect based on that. But even this simple redirect script doesn't seem to work. ```typescript export const auth = betterAuth({ // other config...

Question about Access Control and Orgs

Hey. I'm relatively new to the world with Teams and Orgs. In my previous projects there were only like site Admins, Moderators, users and maybe guests. Now I would like to try the new Permission stuff in the Org plugin but I don't really know how to set it up the best way. My first thought would be creating one Org that holds all users of the page. Then deactivating org creation etc.. and set max members to a very high number. If later social features would require it I can introduce additonal orgs. Or how should I set it up? Currently and in the near future there is no need of multiple orgs or teams. Thanks!...