Better Auth

BA

Better Auth

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

Join

bug-reports

help

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!...

Send session on each request

Should we send the session or access token as a bearer token on each request or does it already do that?

Phone number sign up doesn’t create a record in the Account table?

Hello I want to use better-auth for my nextjs app with phone numbers only authentication. sign up is fine but login complains that there’s no credential account found. This is my code for sign up right now that works correctly: await authClient.signUp.email({...

How to add query parameters to Polar checkout URLs?

Hey there, following https://docs.polar.sh/features/checkout/links#query-parameters you can add parameters like discount_code to the checkout url and have them prefilled in the UI. – That does not seem to work with the Better Auth plugin. Do I miss anything? I've tried: https://localhost:3000/api/auth/checkout/pro-annual?discount_code=X...

Custom Fields in Organization Table Not Saving Values

I'm having an issue with custom fields in the organization table. I've added company_size to my organization schema, but although the field exists in the database, the values I pass are never saved (always null). Here's my organization plugin config: ```typescript...

Change User table primary key name

Hi everyone, is it possible to change user table primary key? This is what i've dont but it doesnt seem to work for primary key field: ```js export const auth = betterAuth({ database: prismaAdapter(prisma, {...

How to Host better-auth on another Server

Hey, How can I host a my App (domain.com) separate from a better-auth Server on e.g. (auth.domain.com)? And Optionally how can I use that better auth Server for Allowing sign-in to multiple different Apps (for example like Google, Google Docs, YouTube) Thank you all...

Issue with error redirection in case of a custom domain setup

I am building a no-code tool to build custom apps. Each app can have multiple users (email/pass based login). Each app is hosted on its own subdomain app1.domain1.com, app2.domain2.com, and so on. When better-auth is used in a custom domain/multiple subdomain setup, the base URL is not known at build time but rather at runtime. When logging in via a social provider, let's say Google, if there is an error, the redirection is made to the baseURL defined in the context: throw c.redirect(${c.context.baseURL}/error?error=state_not_found); The ideal redirection should be to the client's subdomain. What is the best way to go about this?...

Trigger Session update ( to update user data)

Hey im updating user data after signin with google basically I assign a username and a checkbox to agree TOS. User is always redirected this onboarding page as long as he has 'pending' role. basically, after he submit his data i update him to a user role and he can browse the app now. How can I trigger/refresh session data to get the current state of the user from db? ...

additionalFields need defaultValue even for non required field

Hey i have the error that there isn't defaultValue on my field but my fiel has to be not required, and i try to connect using google oauth, on my express app. Can someone help me understand why it says it needs a defaultValue (and i try with or without the line defaultValue: "" but same issue) ? thank you all 😉...

Cross domain cookie / backend behind cf tunnel

Hi everyone, Does anyone have a setup where the back end is behind a cloudflare tunnel? I am dealing with a cross domain cookie issue and would love some help on resolving it. ...

The inferred type of 'authClient' cannot be named without a reference to [email protected]

Currently having an issue with undici:
The inferred type of 'authClient' cannot be named without a reference to '.pnpm/[email protected]/node_modules/undici-types'. This is likely not portable. A type annotation is necessary.
The inferred type of 'authClient' cannot be named without a reference to '.pnpm/[email protected]/node_modules/undici-types'. This is likely not portable. A type annotation is necessary.
My auth client:...

next.js multizone issues

Trying to set up multi-zone Nextjs app App 1 - Marketing (localhost:3000) App 2 - Dashboard (localhost:3001, with Better Auth) ...

Init Drizzle with cloudflare env variables

I'm trying to connect my database with the drizzle adapter. My backend will be hosted on cloudflare workers (with hono) so I can't use process.env to get my environement variables. How to get my cloudflare env variables to the db init ? Thanks for your help! ...

Stripe one time payments?

Hi everyone. Is there a way to utilize products with the stripe plugin. I understand that subscriptions are the focus of the plugin atm. I need this soon and don't mind creating a plugin for it.

Error in auth with discord

When I try to log in with Discord, it doesn't redirect me to the login page. And the API route even returns that: ```` 0:{"a":"$@1","f":"","b":"development"}...
Solution:
i got fix that 🙂 i added endpoint for my api, and add onSucess in signin haha 😄...

create organization in databaseHooks.user.create.after

I want to ensure that for all created users without an invite link, an organization (using the organization plugin) is created for them automatically on sign up. Ideally also set this freshly created organization as their active organization on the client. Is there a way to create an organization for a user that has just been created? I was thinking of using this database hook: ...

Can BetterAuth’s OIDC provider work with Saleor as an external auth system? If so, what’s the config

I need help from someone who has been able to setup a working OIDC with Better Auth. Thanks
Next