What problem does it solve?
Better Auth provides a framework-agnostic authentication and authorization layer for TypeScript applications. It reduces boilerplate while delivering robust features like email/password, social OAuth, 2FA, passkeys, and multi-tenant support.
Core Features & Use Cases
- Framework-agnostic: Works with Next.js, Nuxt, SvelteKit, Remix, Hono, Express, and more.
- Built-in auth methods: Email/password and multiple OAuth providers.
- Plugin ecosystem: Add 2FA, passkeys, magic links, username, email OTP, organization, and more.
- Database & ORM flexibility: Supports SQLite, PostgreSQL, MySQL, MongoDB, with adapters for Drizzle, Prisma, Kysely.
- Type safety & session management: End-to-end type-safe auth with session handling.
- Multi-tenant & user management: Designed for organizations and teams.
Quick Start
- Install the package: npm install better-auth (or pnpm add better-auth, yarn add better-auth, bun add better-auth)
- Configure environment: BETTER_AUTH_SECRET and BETTER_AUTH_URL
- Create your auth server instance and connect your database
- Mount the API handler in your framework of choice (e.g., Next.js: app/api/auth/[...all]/route.ts with toNextJsHandler)