Use auth.api as request only?
I'm using auth.api across multiple apps. They don't necessarily share the same DB, but I keep getting a "this relation does not exist" error when trying to use it.
Using just fetch works without a problem. Any suggestions...
Cant get listUsers in the admin plugin to work
const usersQuery = useQuery({
queryKey: ["users"],
queryFn: async () => {
return await authClient.admin.listUsers({
query: { limit: 10 },...
405 When signing in after deploying
I’m having an issue where when signing in, it uses whatever URL I’m navigated to, like if I’m using a Vercel preview URL it does /auth from that URL, instead of using my preset BETTER_AUTH_URL
Anyone else having a similar issue?...
trpc
Hi, I want to "connect" my electron app to my nextjs server using better-auth with an admin plugin. How would I be able to connect an account to the electron app then get the users permissions to then do some things depending on these permissions? For login in would my best choice be an electron deep link?
Environment Variables not found
Hi, I deployed my Next.js project using Vercel, but in production I'm getting these messages.
Checklist:
I checked my environment variables in the host.
...

Unable to check permisions
When I do this
```
export async function updateUser(id: string, payload: Partial<User>) {
const canCreateProject = await authClient.admin.hasPermission(
{...
Unable to set cookies in hooks
I'm not able to set normal or signed cookies in hooks.
```js
hooks: {
before: createAuthMiddleware(async (ctx) => {...
Shareable links
I’m planning to make parts of my dashboard shareable as reports — similar to how you can share files in Figma.
Has anyone already implemented something like this with better-auth?
I’d love to hear your ideas on how to approach this.
Currently, I’m using Next.js....
Privilege elevation?
Hello,
First of all, this is a very nice library — thank you for your work!
I had a question: is there a way to implement temporary privilege elevation?...
No page refresh after sign in or sign out?
I have created a simple Next.js application
- I use sign (with email/password) with a server action that creates a cookie (from auth.ts)
- I use sign out with a client action (from auth_client.ts)...
[OIDC] Post-consent authorization in refresh token flow
- BA as OIDC OP (OIDC provider plugin)
- Auth.js as OIDC RP
client.oauth2.authorize(...)
with offline_access
scope + prompt=consent
parameter works the first time (redirects back to client after accepting consent with client.oauth2.consent(...)
) along with a refresh token, however subsequent requests trigger a 500 error. They work again if I delete the corresponding record in the oauth_consent
table. What am I doing wrong in the flow? Can share more details as needed (query parameters passed to .authorize
, etc.)...Open api with exchange token
Hey!
I need to create a public API (machine to machine) where our users will have to generate a key. the key is created by a user but attached to a company
(1 user belong to many company, 1 company has many users)
This is the flow:
1. user creates a key "A" in the context of a company...
Mongodb indexable?
So I was reading the optimizing for performance guide. Is it possible to index the fields in mongodb for faster auth times?
Google auth on plasmo browser ext
Is it possible to use plasmo and have google auth with a plasmo framework extension?
I see that the example uses password and username, but I’d like to add google auth. What would be those steps?
I have a full Nextjs website with the Google auth setup already...
Custom format for API Key
I need my API keys to be a UUID v4 (the software that it interfaces with requires the keys to be formatted that way) - how can I do this with the API key plugin?
Solution:
Solution:
```ts
plugins: [
apiKey({
customKeyGenerator: async () => {...
Soft Deletes
Hi! I had a broader question around how BetterAuth is intended to support soft deletes across different entities (users, organizations, invitations, etc).
In our system, we soft delete records by setting
deletedAt
to a non-null val rather than hard-deleting them. I'm running into some challenges where BetterAuth’s core logic doesn't seem to account for soft-deleted entities.
For example, when creating an invitation, if a user’s email already exists (even if soft-deleted), it throws an error. Similarly, creating users or organizations could conflict if soft-deleted records aren’t ignored during validation....inferAdditionalFields
What is the purpose of inferAdditionalFields (this is mostly rhetorical) because the returned user object from signin email doesn't have additional fields even if specified and if you don't put inferAdditionalFields in your client config the fields are added by default to the user returned in the session.
I am confused on the purpose because it doesn't seem to do anything. I am likely doing something wrong somewhere....
Solution:
I'm good. The documentation helps:
https://www.better-auth.com/docs/concepts/typescript#inferring-additional-fields-on-client...

Extend type user
```user: {
changeEmail: {
enabled: true,
sendChangeEmailVerification: async ({ newEmail, url }) => {
///...
Solution:
Found a quick fix adding this in the auth.ts
export type User = typeof auth.$Infer.Session["user"];
export type User = typeof auth.$Infer.Session["user"];
Manual User SignUp
I'm only using google for signup . But suddenly my team asked me if we could manually signup user . Is there any way to do that? As google provides several data that are need for the user, account table and other 2 tables.
Get session call failing Safari
Hi, I’ve recently setup better auth with nextjs, using the drizzle adapter and nextCookie plugin. I wrote my own plugin for steam authentication (OpenID 2.0), which seems to be working good.
However, one weird bug I’ve seen is that on safari, the get session call made when the user clicks my sites sign in button throws an error with status 0 and status text as an empty string.
Any idea why this is happening? Thanks!...