Better Auth

BA

Better Auth

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

Join

bug-reports

help

Generate magic links without sending

Hi guys! I have this use case where I want an admin to be able to generate magic links for other users and send them as the user wish. Can't seem to find a way to do this. Any help is appreciated šŸ™‚

additionalFields suggestion in swagger

is it normal i don't have this extra fields in my swagger suggestion ? note: it does work when i write manually....
No description

how to management active organization between session tabs

hi, I’ve been trying to understand how I can management my active organization between session tabs I know I can set my active organization in my user session, but, If I handle with multi-tenancy in tabs, this will not be useful ...

Session doesn’t get invalidated after the user is deleted

I tested what would happen if I deleted a user manually from the database and when I refreshed the page it stayed in the same page, it didn’t redirect to the auth page. I tried using these 2 method in the middleware: - https://www.better-auth.com/docs/integrations/next#for-nextjs-release-1517-and-below - getSessionCookie() and got the same result, it thinks the session still exists, also the better-auth.session_token cookie doesn't get deleted either. How to solve this issue? It’s been a day and I still haven’t figured it out. Any help would be appreciated!...

Migrate command doesn't work

I'm using Supabase. I have been following the installation guide, and so when it comes to run the migrate command, I run it, it asks me about installing the package, then nothing. I can't see any new tables in Supabase.

Include relationship in session.user object?

Hey there šŸ‘‹ I'm looking to perform a check in a Next.js layout that sees how many related posts records exist for a user before redirecting or granting access. Now, I could just denormalize the count of these records into a column on the user record, but maybe there is another way. ```ts import { customSession } from "better-auth/plugins";...

Pure postgresql with better-auth

Hey folks, is there an example on how to use better-auth with pure PSql locally? Im having troubles alone
Solution:
all good, either to simplify your life when setting up the project or just to keep everything together, a lot of people deploy using Docker

Best practices for a monorepo that needs to share sessions across apps? Next.js multizones

Has anyone ever implemented better-auth in a Turborepo monorepo that needs to share auth sessions across apps? I'd love to have my 2 monorepo apps at /feed and / be able to share session state. When someone logs in to one, I also want them logged in to the other, etc. Seems like this could be achieveable with Next multizones since they'll be on the same domain, but not sure how best to approach this from better auth. Maybe an auth package also in my monorepo?...

How to add custom fields on Sign-up?

How do you add custom fields to client side functions like sign-up? I am working on a sign-up form in nextjs app router and I have better-auth working with the basic email, password, name, etc. fields using: const { data } = await authClient.signUp.email(...

stripe plugin & Polar plugin for payment

if i use stripe plugin & Polar plugin tgt , will there any problems?

Cannot verify TOTP after successfully setting up 2FA, getting `INVALID_TWO_FACTOR_COOKIES`

I can successfully enable TwoFactor, show the QR and backup codes, and verify it with a generated code. This sets twoFactorEnabled to TRUE for the user. However when that user later logs out and back in, and needs to verify their 2FA TOTP code, I get this error INVALID_TWO_FACTOR_COOKIES. No two factor cookies are being set anywhere, and I have tried to log them but they aren't generated by the enable nor verify TOTP in my totp/setup routes. What could be the issue? Thank you....

how to listUser from admin plugin?

I'm having trouble listing the users of my application using the admin plugin, I used the code provided in the documentation but I'm still having trouble.
Solution:
On the server, you must use auth.api
No description

BetterAuth as OAuth2 Server

Hi everyone, as I have recently read more often the requirement that BetterAuth is used as an authentication server and e.g. is hosted on another subdomain and serves as an identity server, and I also have the same requirement myself. I wanted to ask if it is planned to develop BetterAuth itself as an oauth2-oidc server in the future, because the current procedure (I think the only possibility is to put the auth cookie on the main domain) is rather unattractive and an OAuth2 server would have some advantages and would be a clean solution....

Can i use Better-auth api in nodejs which exposes my auth route to frontend on flutter

i am want to use better-auth in nodejs as server side auth and expose my api to frontend which is in flutter can we do it

How to handle deleted user?

I have a next app set up with auth using better-auth. I'm using basic middleware like this ```import { getSessionCookie } from "better-auth/cookies"; export async function middleware(request: NextRequest) { const session = getSessionCookie(request);...

genericOAuth discoveryUrl TypeError: Invalid URL

# SERVER_ERROR: [TypeError: Invalid URL] { code: 'ERR_INVALID_URL', input: 'undefined' }
POST /api/auth/sign-in/social 500 in 1873ms
# SERVER_ERROR: [TypeError: Invalid URL] { code: 'ERR_INVALID_URL', input: 'undefined' }
POST /api/auth/sign-in/social 500 in 1873ms
...

How to login right after signing up with OTP email?

Does betterauth have a way to create a session from the BE immediately after signing up with email OTP?

Prisma Adapter not generating Additional Fields for Organization

I had a lot of work with my config auth file, the modelNames work, the aditional fields for user work, but the custom field names and the additional fields are not being generates correctly using the prisma adapter:

I am gettng internal server error and not understanding why, how to get logs

anyway to debug this?
GET http://localhost:3000/api/auth/get-session 500 (Internal Server Error)
GET http://localhost:3000/api/auth/get-session 500 (Internal Server Error)
...
Solution:
That line is outputting the result of a GET request I would imagine the 500 is emitting some error to the log server-side? Are you sure there's nothing else in your console? You could try adding logging to your Next.js API route handler like this and interrogating the request to see if anything looks odd: ...