Better Auth + Expo GO
Hey everyone, I'm quite new to Better Oath and ExpoGo, so it might sound like a newbie question. After a lot of investigation with Cursor, Gemini, and looking on the web, I couldn't find my answer, so I'm asking for help here.
I'm stumbling upon a problem where I want to set up Discord authentication using BetterAuth in my app and I want to test it with Expo Go. I'm currently working on a mono repo, so my backend is defined in Next.js and I have a web app to compare and test with. BetterAuth works pretty well with it, whether it's locally or on Vercel, but I cannot manage to make it work on the app.
The problem is as follows: Whenever I try to sign in with Discord on the Expo Go build of my app, the Discord authentication window opens, I put my credentials, and they are validated. But when I'm redirected to the app, the session is not updated, and not considered as logged in....
Getting error only in production and not locally
Getting this error in production
```
SERVER_ERROR: TypeError: Cannot read properties of undefined (reading 'serialize')
at h (.next/server/app/api/chat/route.js:4:53602)...
Show API Reference (openAPI plugin) only in development
Hey, how can i conditionally show the API Reference only in development?
authClient help
How to make it so, with auth-client signUp, i can insert other stuff than email and name?
generate cli show no output
no schema generated in schema.ts file, path to schema file is (./server/db/schema.ts)

OTP password reset
is there a method to verify the password reset OTP sent to user?
according to the current better auth password-reset flow with OTP we need to send OTP + new password + email and it should work, but our flow requires the OTP verification before showing the password inputs for the user.
i've found a method called
getVerificationOTP
but that also re-sends a new OTP for the user and returns ...Solution:
I believe the OTP is already saved in
verification
table of your dbFinding Drizzle schemas for the better-auth "admin" plugin
I'm working with a Turborepo setup using Bun.js and I've placed my better-auth setup in a @repo/auth package.
I'm running into an issue where I can't get the @better-auth/cli migrate command to run, so I'm trying to figure out how to set up my schemas manually to use the "admin" plugin.
I checked the better-auth repo and found the base schemas here:
better-auth/better-auth/packages/better-auth/src/adapters/drizzle-adapter/test/schema.ts
Use code with caution....
Solution:
I think that all you need is to follow the core schema here:
https://better-auth.vercel.app/docs/concepts/database#core-schema
And then add the schema here:
https://better-auth.vercel.app/docs/plugins/admin#schema...
Getting 405 on Vercel
I am trying make betterauth to work on Vercel, but for some reason all calls to /api/auth/* return 405 Method Not Allowed. Works locally, other endpoints work on Vercel. Using Next.js 15 and better auth v1.2.12
Solution:
Oh nevermind, I had incorrectly configured vercel.json file with this line. Deleting the file solved the issue
...
{ "source": "/(.*)", "destination": "/" }
{ "source": "/(.*)", "destination": "/" }
Prevent users without Stripe subscription from hitting API endpoints
I want to ensure users can't hit certain API endpoints without an active Stripe subscription.
Is there a better way than checking the subscription table on each request in middleware?...
2fa cookie issues
POST /api/auth/two-factor/send-otp
{"code":"INVALID_TWO_FACTOR_COOKIE","message":"Invalid two factor cookie"}...
Solution:
nextCookies(), has to be the last plugin
better-auth-ui
hey how can i send additional data like some id with the sign up request without showing on the ui @daveycodez
twofa schema is missing
SERVER_ERROR: [Error [BetterAuthError]: [# Drizzle Adapter]: The model "twoFactor" was not found in the schema object. Please pass the schema directly to the adapter options.] {
cause: undefined
}
POST /api/auth/two-factor/enable 500 in 987ms...
Solution:
had to export it
BetterAuthOptions database.casing?
Could someone please advise on what the
casing
option in BetterAuthOptions
does?
It is referenced in the docs here:
https://www.better-auth.com/docs/reference/options#database
...auth.api.getSession() Causing Issue on Vercel Build
i am trying to fetch the user session on the server to do some stuff with it and it works fine when running in locally, but when i build it on Vercel edge function and deploy it, it gives me a server error saying I'm calling localhost?
I assumed maybe its the env variable so i logged it in build time and it is the correct domain
what could the issue be?...

Verify TOTP before resetPassword
I use SvelteKit and have applied BetterAuth's API calls server-side. I'm using a SvelteCookie plugin to ensure these are passed to the client.
I want to solve for this use case:
User signs up, verifies their email and sets up 2FA TOTP. Later, they want to reset their password. How do I ensure their TOTP is checked before they can trigger
requestPasswordReset
? ...Cookie do not return on server (Hono)
Hi everyone,
I've been working on an experimental project that combines React Router v7 (using framework mode) with Better Auth. For the backend, I'm using Hono along with the react-router-hono-server package.
The login flow works fine, and I can successfully retrieve the user's session on a protected page via React Router. However, when I try to access the session inside a Hono middleware, it’s not available.
Am I missing something in the setup or configuration?
For context, here are the headers returned from the React Router loader compared to those in the Hono middleware:...
how can i prevent discord auth to automatically create new accounts?
basically i want the user to be able to sign in with discord only after he linked his discord account
Solution:
haven't tried it but seems like you just set it to false and it does what you want
Reusing Emails (soft delete feat)
hello everybody,
I’m working on a project using BetterAuth and I have a question about handling soft-deleted users.
In my setup, I have a users module and I’m creating users using the auth.api.signup method (with email/password). I’ve also implemented soft deletion by just toggling a boolean field — if deleted = true, the user is considered deleted.
...
Solution:
Yes it's still considered taken as Better-auth doesn't know that you have a soft-delete feature.
We plan to support soft-delete in the future. In the mean time, I recommend modifying the existing soft-deleted user's email to have a suffix/prefix of some sort so that the email slot opens up for other users to sign up with....
I am new, can I use better-auth with rust backend?
My backend is in rust, I looked at the better-auth I loved it but they have only js implementation for backend. Is there any rust backend version or can I use client side only auth (I don't know how the db communicates without getting compromised).
My frontend is React...
cookiePrefix fucks up nextjs middleware
```
import { getSessionCookie } from "better-auth/cookies";
import { NextRequest, NextResponse } from "next/server";
export async function middleware(request: NextRequest) {...