Can I use Better Auth with [framework]?
Can I use Better Auth with [framework]?
Better Auth is framework-agnostic. It exposes a standard
Request /
Response
handler that integrates with any server framework that supports the Web
Fetch API, including Next.js, Nuxt, SvelteKit, Astro, Hono, Elysia, Remix,
Express, Fastify, and more.Framework-specific helpers (e.g. toNextJsHandler) are available in the
better-auth package for the most common runtimes.Does Better Auth support edge runtimes?
Does Better Auth support edge runtimes?
Yes. Better Auth runs on edge runtimes such as Cloudflare Workers and
Vercel Edge Functions. Make sure the For best results on serverless/edge platforms, pair it with a compatible
database (e.g. Cloudflare D1, Turso, Neon) and optionally a KV store for
sessions.
nodejs_compat compatibility flag is
enabled in wrangler.toml for Cloudflare Workers:wrangler.toml
Is Better Auth production-ready?
Is Better Auth production-ready?
Yes. Better Auth is used in production by many teams. It is actively
maintained, has a comprehensive test suite, and follows security best
practices (CSRF protection, scrypt password hashing, secure cookies, rate
limiting, PKCE for OAuth, etc.).
How do I add custom fields to the user?
How do I add custom fields to the user?
Use the Set
user.additionalFields config option:auth.ts
input: false for fields that should not be writable by end users
(e.g. role, banned). See the
TypeScript docs for type
inference on the client.How do I rotate my secret key?
How do I rotate my secret key?
Use the Existing encrypted data (sessions, tokens) is automatically re-encrypted
with the new key on next write. No downtime or database migrations are
required. See the security docs for
details.
secrets option (plural) to perform a non-destructive rotation.
The first entry becomes the active key; additional entries are
decryption-only:auth.ts
Auth client not working
Auth client not working
Make sure you are using the correct import path. It differs by environment:
getSession not working on the server
getSession not working on the server
authClient.getSession() cannot access cookies in server environments.
Use auth.api.getSession and pass the request headers:server.tsx
fetchOptions:Difference between getSession and useSession
Difference between getSession and useSession
useSessionis a React hook. It triggers re-renders when the session changes and is suitable for reactive UI updates.getSessionreturns a plain promise. Use it anywhere a hook cannot be called: server components, route handlers, server actions, or non-React environments.
Can I remove name, image, or email from the user table?
Can I remove name, image, or email from the user table?
Not currently. The
name, email, and image fields are part of the
core schema. Greater schema customisation is planned for a future release.Common TypeScript errors
Common TypeScript errors
Enable If you cannot use
strict mode in your tsconfig.json:tsconfig.json
strict, enable strictNullChecks at minimum. See the
TypeScript docs for more.Dual Module Hazard: 'No request state found'
Dual Module Hazard: 'No request state found'
If you see an error like:This is usually caused by multiple versions of Fix — clean reinstall:Next.js — add to Cloudflare Workers — enable Node.js compat:Yarn v1 / pnpm v9 — force
better-auth or
@better-auth/core in your dependency tree.Diagnose:serverExternalPackages:next.config.ts
wrangler.toml
better-call to a single instance:package.json
How do I configure a corporate proxy for outbound requests?
How do I configure a corporate proxy for outbound requests?
Use
undici’s ProxyAgent to set a global dispatcher before creating your
auth instance:auth.ts