Better Auth

BA

Better Auth

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

Join

bug-reports

help

300+ type errors in better auth packages when attempting to build the project

When I attempt to build the project with tsc (node+express app), I get 321 type errors from better auth packages.
No description

Is there a way to use the permissions API without admin or organization plugin?

Just wondering about the above, I liked the permissions api built into those plugins, and organization doesn't work 100% for my use-case.

Cookie not being set when using live lambdas

hey using a live lambda to proxy better auth to aws, however the cookies are not being set when calling authClient.signIn

Session still active after calling authClient.revokeSession

I've got a button that does this: onClick={async () => { const res = await authClient.revokeSession({ token: session.token,...
Solution:
Found the solution. I had this on my auth.ts file that was preventing the session to be immediately terminated: export const auth = betterAuth({ database: drizzleAdapter(db, { provider: "pg", // or "pg" or "mysql"...

403 error when listing user from superadmin role

auth.ts ```tsx user: { deleteUser: { enabled: true,...

Use auth on client or server (NEXTJS)

Hey, for security and optimization reasons, should I use server-side authentication (e.g., await auth.api... in a server component) and pass the result to the client component when needed, or is it better to use the client-side authentication directly (authClient)? In which cases should I use one over the other?...

better-auth organizations

When running organizationCreation's beforeCreate and afterCreate I don't see any request being passed in. It's only the organization details even though I am passing in the headers directly to the api (because I'm calling this from the server). ```ts // Organization plugin setup organization({...

Access token from Social Login

I am migrating from Supabase. Everything works well until I tried to find out how can I get the provider token (from Google) after a successful login. I am using more roles on login and then after I want to use the token to authenticate to some Gmail APIs. I tried to get on authClient.useSession and authClient.listAccounts() . Is there a way? I am using Hono on backend and React with Vite on frontend....
Solution:
Better Auth doesn't expose the provider tokens on the client. You can make an endpoint and fetch the accounts table.

Change password from the server

how do I change the password (from the email + password credentiales) from the server? My understanding what that authClient is meant to be used in the client and that, in the server, I am expected to use auth.api.changePassword, as in: ```ts...
Solution:
You need to pass the headers of the user making the request.

Set active org on login

I want each user to always have one active org set when they log inn, no user should ever find themselves without an active org. Docs at https://www.better-auth.com/docs/plugins/organization indicate that I can use a database hook to achive this ```js export const auth = betterAuth({...

How to save ip addresses into the session table

Do I need to make a few extra settings? IP addresses are not being written to the database.
No description

you are not allowed to list users 403 error

i want to create superadmin for the owner of sas project, auth ```tsx additionalFields: {...

Stripe: how can we renew a cancelled subscription

I am trying to find a way with better auth to access the stripe billing portal again after cancelling a subscription, right now better auth throws an error when the cancel fct is called but the subscription is already cancelled, and from what I know this is the only way to access the billing portal from better auth

How to log sign-in, sign-out, and errors?

Hi, How can I log user logins, logouts, errors, and other actions in the Better Auth library? I’m using it in a Next.js. Is there a built-in way to handle logging, or do I need to implement custom event tracking? Thank you...

Cant delete API_Key

I get 404 when using the delete. _ const handleDelete = async () => { if (!selectedKey) return; ...
No description

Feedback on Using Hooks for Email Verification After Sign-In

Hey everyone, I’m working on a project where I need to manually verify a user’s email on their first login and then update an external system with the user's application status afterward. I’m using a hook after sign-in to check if the user’s email is verified, and if not, I update it and then send an external status update....
No description

Why does the session disappear after refresh?

Here, I am retrieving the session from authClient, but when I refresh the page, the session data disappears. What is wrong here?
No description

support both MagicLink and OTP

How to enable the verification by both ways together, client can verify either by entering OTP sent in email or clicking the "verify-link" can anyone help me on this, thanks in advance...
No description

Argument `id`: Invalid value provided. Expected String, provided ().

I'm making a plugin and got this error: `` prisma:error Invalid prisma.wallet.create()` invocation:...
Solution:
Im just stupid, wrote fieldname: "id" which broke it

how do you run a function after user creation?

i want to create a personal organization for users by default