Better Auth

BA

Better Auth

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

Join

bug-reports

help

Tanstack Start Server functions cookie issue

Hi, I'm having trouble getting session_data cache cookie to update when I use the auth api inside a tanstack start Server function. It is similar to next.js I think, and I have recreated a version of the nextCookies() plugin for tanstack start. problem is it works perfectly in development server, but not in vercel/netlify deployment. can anyone confirm if they have the same issue or help? thanks!...
No description

Single Auth Multiple apps setup.

Hi. I am trying to setup a central auth which will be used by multiple apps. I tried creating OIDC but its not working good for me. I came across this comment. How should we go about this. I have nextjs central auth and tanstack start first client app. Do i need auth.ts in tanstack server api routes or only in nextjs central....
No description

How can I extend the organisation plugin?

I need organizations for my tool that have teams, where I can select the active team. It should behave similarly to how it works with the organization, but within the organization.

[# Drizzle Adapter]: The model "team" was not found in the schema object. Please pass the schema dir

Trying to active the teams on organization, already did a migration, but still not able to add it.

Better Auth errors with state not found after social sign in

Any idea what could this specifically mean? after a signin with social provider(github) it would rediret me to the error page with the state_not_found error

.cursor/rule For Better-Auth

Hello, is there a cursor rule for better auth docs?

Betterauth CLI Fails on sqlite

https://www.better-auth.com/docs/adapters/sqlite After following guide from docs, Cannot generate using see error messages....

Next Auth `iss` claim missing

Hi, I'm not sure whether to ask this in Next Auth/Auth.js server or here, but I assume here because the same Next Auth config works for other OIDC providers without modification. When attempting to sign in with Better Auth + OIDC plugin, I receive this error from Next Auth: OperationProcessingError: JWT "iss" (issuer) claim missing. Attached screenshot of supported claims from well-known endpoint on BA side, as you can see iss is listed, which makes me think BA is not the problem. Any ideas? If this is a Next Auth error after all, I'm confused why it works for other OIDC providers EDIT: also asked in Auth.js server and linked back here: https://discord.com/channels/1200116961590399008/1354958631476531220/1354958631476531220...
No description

Machine authentication (Client Credential Grant)

I'm wondering if its possible to use better auth for machine auth(Client Credential Grant). I have a another app that needs to send data to my app, for this it needs to authenticate. What would be the best way to do this? I was not able to find this in the docs....

Stripe sync subscriptions

How can I sync subscriptions which got created with stripe dashbaord that I have that subscription in my database as well? I using the stripe plugin so far...

How to know if the signed in user is a new user? (For both Password and OAuth)

Hi, I am building my SaaS using better-auth and Nextjs. I want to create a doc in the MongoDB for the new users. However, I am not able to figure out how to do this. Please help me. my setup:...

SignOut function doesn't immediately re-invoke session change

Hi, everyone I am currently implement auth in my project I followed the quick start from docs and it went smoothly But when I implement sign out and click it, it doesn't immediately show logged out display instead I have to reload the page to see the change? ...
Solution:
```ts export default async function MainLayout({ children, }: Readonly<{...

Get access to genericOAuth profile in customSession

Hi everyone, I have some user groups in keycloak and want to pass them to session.user. The groups are in the genericOAuth profile, as passed to mapProfileToUser. How can I access profile.groups from customSession? Thanks!...

Not able to get session type while using auth.api.getSession({headers: headers()})

I have an turborepo setup with below packages, i am trying to migrate from "next-auth" to "better-auth". I have all auth related code in seperate internal package "packages/auth". I facing very strange issue on which i am stuck from last 2 days. My problem is related to getting types for session, I am using auth.api.getSession to get session on serverside. I have tried everything, even when i am using this in auth.ts file itself it is not giving types. I have tried to use differnt tsconfig....

Help setting up better auth in a fetch environment

Hey! I am getting a 404 error when trying to call the better auth handler in my api handler. Does anyone know how I can solve this?
No description

Database Hooks within a Plugin

Hi, I'm working on a custom plugin which requires intercepting and editing the user data when a user is created. This would be easier with a database hook, but I cannot find a way to do a database hook in a plugin. Is there a way of doing this? Thanks....
Solution:
you can pass init ```ts const plugin = { init: (ctx)=>{ return {...

Where to get these ID token? the documents looks half.

Sign In with Google With ID Token To sign in with Google using the ID Token, you can use the signIn.social function to pass the ID Token. This is useful when you have the ID Token from Google on the client-side and want to use it to sign in on the server. ...

Auto logout

Hi, Im using nextjs + mongodb and Redis for caching. But when I update the site, some users getting logged out. and some was saying that it takes a few minutes to login again....

Infer additional fields for admin?

Is admin not able to infer types for additional fields like so when the types come from a plugin? I have added the InferTypes on the client plugin. ``` await admin.createUser({ name, email,...