Better Auth

BA

Better Auth

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

Join

bug-reports

help

Magic Link email validation and error handling

I've followed the docs on how to implement magic link, however i feel there is a few things missing from the example, email validation and error handling. Can someone please guide me in the right direction with the syntax and or structure of how to implement this? ``` const [email, setEmail] = useState("")...
Solution:
I figured out how to pull errors: const {error} = await authClient.signIn.magicLink({ and validation can be done before calling signIn.magicLink...

How to useSession with cross sub domain cookies enabled

I would like to get the user's session on the client. How can i achieve this ? With my current implementation it doesnt return the session...

Missing valid authorization header

When using the Twitter provider, the error "Missing valid authorization header" appears. Is there any configuration missing? Version: 1.2.9...
No description

authClient.organization.setActive() returns all the members of the organization

Hi, when I call authClient.organization.setActive(), I'm getting a response with a fully-populated members property that lists every member of that organization, including their email addresses. Is that intended? Seems like if I am just trying to sign the user into a tenant, there's no reason necessarily to respond with a list of hundreds or thousands of users?

Changing user's id data type

Is it okay to use uuid as the data type for user's id? Does it have to be text? Will that cause any problems down the line? ```export const user = pgTable("user", { id: uuid("id").primaryKey(),...

Expo Apple Signup on Local Development

I followed the documentation of the expo plugin and the apple plugin. But I am getting a very unhelpful error message from apple saying: Sign up not completed" without any additional error logging anywhere. Does anyone have experience with how to debug this? I get 0 information on what could be going wrong. I am using monorepo with nextjs backend. I already confirmed email signup is working correctly. I get this data from the initial onSuccess when I call the social.signIn endpoint: https://appleid.apple.com/auth/authorize?response_type=code+id_token&client_id=services.ample.app.dev&state=[my-state-here-not]&scope=email+name&redirect_uri=http%3A%2F%2F192.168.0.55%3A3000%2Fapi%2Fauth%2Fcallback%2Fapple&response_mode=form_post...

How to set cookie in Express?

I am trying to use the better-auth api methods, I followed the docs and I did everything that was mentioned, but everytime I try to sign-in or sign-up, I find that the cookies are missing, I will share with you the code I have in case I made a mistake and I am not conscious of it: ``` // handlers.ts import type { Response } from "express"; import type { SignInRequest, SignUpRequest } from "./request-types";...

Full Page Reload After Forgot Password When Using redirectTo Package: @daveyplate/better-auth-ui Ver

When using redirectTo={domain} with React Router and the built-in forgot-password flow, a full page reload is triggered after submitting the form and the email is sent. This causes an unwanted reload (flicker) and breaks client-side navigation. Expected Behavior...

Help me setting up better auth with drizzle

I'm setting up better-auth with drizzle. I set up all the files needed to configure the db. I also ran generate command and it generated auth-schema.ts. So here are my questions: 1. Can I move what's inside auth-schema.ts to db/schema.ts to keep all schemas in one place (just like what's shown in Drizzle's documentation)? 2. After that, can I simply run npx drizzle-kit push to generate the tables in the database?...
Solution:
Yes

How can I trigger a rebuild of BA's generated types?

For some reason BA has lost its typings after I updated some of my packages (including BA) and now the stripe specific types are missing. IDE keeps telling me that stripe functions like the upgradeSubscription or listActiveSubscriptions do not exist, but the app works perfectly fine. Is there a way to trigger BA's type generation? Couldn't find anything about it in the cli docs.
No description

How to change microsoft authorityUrl?

Is there a way to change the authorityUrl for microsoft to 'https://login.microsoftonline.com/common' instead of 'https://login.microsoftonline.com/<tenant-id>'? I can't seem to find anything in the docs. I'm trying to enable authentication for personal accounts....

How to access the full custom session in a middleware?

Hi! I’m trying to access my full custom session inside a middleware, but it seems like getCookieCache() doesn’t return my custom session data. Currently, I’m calling betterFetch('/api/auth/get-session') from the middleware as a workaround, but I’m wondering if there’s a better or more efficient way to directly access the complete session (including custom fields) within middleware? Any tips or best practices would be greatly appreciated. Thanks in advance!...

Custom runtime scope for microsoft provider

Hi, im having trouble requesting additional scopes when signing a user in specifically using microsoft, my auth is configured like this ``` socialProviders: { microsoft: { clientId: process.env.MICROSOFT_CLIENT_ID || "",...
Solution:
No description

Better Auth Organization Plugin Issue

Problem: The Organization.useListOrganizations() hook consistently returns 403 Forbidden errors despite proper authentication and valid organization memberships. Environment: - Better Auth 1.2.8 with MongoDB adapter - SvelteKit 2.21.1 + Svelte 5...

CAPTCHA Service Unavailable on GitHub Signup/Signin with Better Auth v1.2.9 and Better Auth UI v2.x

Hi everyone, I'm using the latest versions of both better-auth (v1.2.9) and better-auth-ui (v2.x). I’ve successfully configured GitHub OAuth, and sign-up with GitHub is working, but sign-in and regular sign-up are failing with the following error: swift Copy...

better-auth middleware takes around ~5s to resolve

better-auth do a db call when a post req is sent to "/api/auth/get-session" in the middleware?

Get account for current session

Let's say I have access to a website with both an email account and a social account. How can I determine which type of account I'm currently logged in with? How could I store this information in the session?

How to use better-auth to only allow people from my institute to sign-in?

I have seen a hosted domain (hd) parameter and seen a few resources like https://stackoverflow.com/questions/10858813/restrict-login-email-with-google-oauth2-0-to-specific-domain-name but I how to implement this in a nextjs project? I am a beginner in better-auth please help🙏
Solution:
You can use hooks to modify your authentication logic, take a look at the docs: https://www.better-auth.com/docs/concepts/hooks...

Passkey login neither redirects to provided callbackURL nor re-renders UI untill manual refresh

NextJs Middleware: ``` import { NextResponse } from "next/server"; import { getSessionCookie } from "better-auth/cookies"; ...