better-auth

Implement authentication and authorization for TypeScript applications across frameworks.

Updated Jul 23, 2025
One-click install
npx skills add https://github.com/levanminhduc/LuongHoaThoNew --skill better-auth-levanminhduc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: better-auth
Source: https://github.com/levanminhduc/LuongHoaThoNew/tree/main/.claude/skills/better-auth
Command: npx skills add https://github.com/levanminhduc/LuongHoaThoNew --skill better-auth-levanminhduc

SYSTEM DOCUMENTATION & REQUIREMENTS

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)

Frequently Asked Questions about better-auth

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up authentication for a TypeScript application without building it from scratch?

Better Auth is a framework-agnostic authentication layer that eliminates boilerplate by providing email/password, OAuth, 2FA, passkeys, and session management out of the box. Install the package, configure BETTER_AUTH_SECRET and BETTER_AUTH_URL, connect your database, then mount the API handler in your framework—Next.js, Nuxt, SvelteKit, Remix, Hono, Express, or others.

Can I use the same authentication system across multiple JavaScript frameworks?

Yes. Better Auth works framework-agnostic across Next.js, Nuxt, SvelteKit, Remix, Astro, Hono, and Express. You configure one auth server instance and database connection, then use framework-specific handlers like toNextJsHandler to mount the API—no rewriting authentication logic per framework.

What authentication methods does Better Auth support out of the box?

Better Auth includes email/password and multiple OAuth providers built-in. Additional methods—2FA, passkeys, magic links, username authentication, and email OTP—are available through plugins. Multi-tenant organization support and advanced user management are also provided.

Does Better Auth work with my database and ORM?

Better Auth supports SQLite, PostgreSQL, MySQL, and MongoDB databases with adapters for Drizzle, Prisma, and Kysely ORMs. Database adapters handle schema generation and migrations via CLI, and you select your database and ORM during configuration.

How does Better Auth handle session management and type safety?

Better Auth provides end-to-end type-safe authentication with built-in session handling. TypeScript definitions are generated from your schema, ensuring type safety across server and client separation, and session tokens are managed automatically.

What are the limitations when using Better Auth across multiple teams or organizations?

Better Auth is designed for multi-tenant support through its organization plugin, enabling team and organization management. However, complex custom authorization rules beyond built-in role and permission structures may require additional implementation.