Better Auth

BA

Better Auth

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

Join

bug-reports

help

Property 'id' does not exist in user on the twoFactor plugin in auth.ts file

Inside the "otpOptions" parameter in auth.ts file, it throws an error "Property id does not exist on type.", Where could I get the user ID that the code needs?

not able to get lastlogin method in my production

I have added last login method and its working fine in my local but returning null in production my sign in and sign up is working fine at both places but the last login method is coming as null i have checked the cookie and it was perfectly set in the cookie...

How to add custom fields in betterauth signup

Hi everyone! I’m working with BetterAuth and noticed that the signup form only provides a single name field by default. I’d like to customize it to have separate First Name and Last Name fields while using the provided files as a starting point. How can I add these custom fields to the signup form without breaking the existing functionality? Any guidance

Restrict discord login to members of specific server or role

outline.dev has this really nice feature, where you can restrict the sign up to only users that are a member of a discord specific server and have a specific role on that server. How could i implement something like that?

Cross domain auth with social login

I have a bit of a weird setup where I require a static sveltekit application to have auth. I use convex for the backend, and I'm able to log in with username/password, after changing cookie settings to allow cross domain auth. Basically my authclient has the baseurl set to https://xxxxx-xxxxx-xxx.convex.site (better-auth is running on convex), and i have sameSite set to none. The issue I run into is when I'm using a social provider (I'm using log in with github at the moment). I have to...

kysley + sqlite how to handle "numeric" boolean types with anonymous plugin and additionalFields?

when using the anonymous plugin and specifying additional fields its unclear which data type to use for sqlite booleans. - sqlite stores booleans as ints (0, 1) - i set a default of 0 ...

Cannot authenticate myself with Hono Deployed

I have successfully deployed Hono on the cloudflare and I am testing the authentication locally on expo web, but I cannot really authenticate myself, even tho it shows success message for registration and login.

Changing Parameter Names in Custom Provider

Hello! I’m trying to use this library by registering a Korean service called Chzzk as a Custom Provider. However, this service requires the parameters clientId and redirectUri instead of the default client_id and redirect_uri when logging in. How can I change the parameter names used in the existing configuration?...

Issues in Production Using Better Auth

Hey everyone, I’m running into an issue with Better Auth in production. I’m using Express.js for the backend and Next.js for the frontend. Even though I’m not using magic links or OAuth, Better Auth keeps adding /callback in the routes, e.g.: Production...

How to return custom fields on authClient.signIn.phoneNumber

Currently there is nothing in the docks that mentions how to return custome fiedls when signing a user in via the phoneNumber api. If anyone has any knowledge or something i missed the help would be greatly appreciated....

[Help][BFF] How to implement BFF with better-auth ?

Hello, I'm trying to implement a BFF architecture with a microservice who will do only authentication with better-auth (Elysia). The thing is : - I want my Auth microservice to run BetterAuth - My BFF will call this microservice to make all auth for my web client...

better auth `sendVerificationEmail` jwt token detected as spam by gmail

I've narrowed down my email templates getting detected as spam by gmail address. When the email contains a URL with the ?token=eyJWTToken.Like.This -- starting today the email always gets flagged as spam. I've tried sending the emails through both ses and sendgrid with same results on my tests. When replacing the token string param on the url in sendVerificationEmail before putting it in my email template -- for example, swapping eyJWTOKen value with perhaps a number `91827398172389...

Session cookie cache doesn't prevent queries on each load

https://www.better-auth.com/docs/concepts/session-management#cookie-cache It appears that maybe it simply means it wont query the session twice but I think it shouldn't query at all unless a request comes back 401. Like sometimes a page loads and immediately redirects to another. right there is 2 session requests at once, completely unnecessary....

New sessions keep expiring after only 1 day, despite config being set to 7 days

Hi, I created a Next.js project with better-auth recently, but I keep running into a problem: every time I create a new session by signing-in, the session expires after only 1 day. I'm not sure why this is happening, it happens even if I specify 7 days for the expiresIn property under session. Attached is a screenshot of what the session looks like in my database and below is my config file. Does anyone have any thoughts why this is happening?...
No description

OAuth Proxy while using Cloudflare

Figured I'd put this here cause there may be others with similar issues. Quick summary of the whole stack: - Express backend locked down with CORS, related origins added, running behind Cloudflare. OAuth proxy url installed with the specific current and production urls set....

How do I make username a required field during sign up?

// auth.ts ```ts export const auth = betterAuth({ appName: 'appname',...

afterUpdate hook receives query result instead of account object

I’m using better-auth@1.3.26 with the drizzle adapter and neon-http setup. The account.update.after hook receives a query result object instead of the updated account. Expected:...

genericOAuth link with other additional field

I’m using genericOAuth for login, but my provider doesn’t return an email — it only provides a phone number or other field. I need to link the logged-in user with an existing account in my database using this phone number. How can I achieve that?