Better Auth AuthThe most comprehensive auth library for TypeScript
Better Auth handles authentication end-to-end for TypeScript apps — sessions, OAuth, two-factor, magic links, passkeys, and more. Framework-agnostic with adapters for every major ORM and database.
Better Auth is the most comprehensive authentication library for TypeScript — handling sessions, OAuth providers, two-factor authentication, magic links, passkeys, and organization management out of the box. It's framework-agnostic, working with Next.js, SvelteKit, Nuxt, Hono, Express, and more. Unlike hosted auth services, Better Auth runs in your own infrastructure with your own database. It supports Prisma, Drizzle, Mongoose, and raw SQL adapters, giving you full control over your auth data while providing a type-safe client with autocomplete for every auth action.
Quick start
npm install better-auth
# Create auth configuration in lib/auth.ts
# Set up your database adapter (Prisma, Drizzle, etc.)
# Add the auth handler to your API routes
# Generate the client
npx @better-auth/cli generateRead the full documentation at www.better-auth.com/docs
Complete auth flows
Email/password, OAuth (GitHub, Google, etc.), magic links, and passkeys — all production-ready.
Two-factor auth
TOTP, SMS, and backup codes with a simple plugin — 2FA added in minutes, not days.
ORM-agnostic adapters
Works with Prisma, Drizzle, Mongoose, and raw SQL — bring your existing database setup.
Framework agnostic
Next.js, SvelteKit, Nuxt, Express, Hono, Elysia — Better Auth adapts to your stack.
Type-safe client
Generated client with full TypeScript types — autocomplete for every auth action and session field.
Plugin ecosystem
Organisation management, admin panel, rate limiting, and audit logs as first-party plugins.
Why it's hard
Initial configuration complexity
Better Auth offers extensive configuration options (plugins, adapters, providers). The initial setup requires deliberate choices about which features to enable and how to structure your auth flow.
Plugin compatibility
Some plugin combinations require specific ordering or configuration. The documentation covers these cases, but reading plugin READMEs carefully before combining them is important.
Self-hosted responsibility
Unlike Clerk or Auth0, you own the infrastructure. This means you're responsible for session security, rate limiting, and keeping dependencies updated.
Best practices
Start with the core, add plugins incrementally
Begin with email/password and one OAuth provider. Add 2FA, organizations, and admin features as plugins once the core flow works.
Use the type-safe client
Better Auth's generated client provides autocomplete for every auth action, session field, and user property — catching auth bugs at compile time.
Configure rate limiting from day one
The rate limiting plugin protects login and signup endpoints from brute-force attacks — essential for any self-hosted auth system.
Useful resources
Frequently asked questions
Related technologies
Related services
Looking for end-to-end delivery? These services complement Better Auth projects.
Want to build with Better Auth?
Talk to our engineering team about your Better Auth architecture. We'll respond within 24 hours.
We limit intake each month so every project gets the focus it deserves.