Skip to main content
Better Auth is a framework-agnostic authentication and authorization library for TypeScript. It provides a comprehensive set of features out of the box — email/password, social OAuth, passkeys, two-factor auth, multi-tenancy — and includes a rich plugin ecosystem that lets you add advanced functionality with minimal code.

Installation

Install Better Auth and connect it to your project in minutes.

Basic Usage

Learn how to sign users in, manage sessions, and use the client SDK.

Plugins

Extend Better Auth with 2FA, organizations, SSO, passkeys, and more.

API Reference

Explore all configuration options and the full public API surface.

Why Better Auth?

Authentication in the TypeScript ecosystem is a half-solved problem. Most libraries require significant custom code for anything beyond basic sign-in. Better Auth aims to be the last auth library you’ll ever need.

Framework agnostic

Works with Next.js, Nuxt, SvelteKit, Hono, Express, Expo, and any runtime that supports standard Request/Response.

Rich plugin system

Add 2FA, organizations, passkeys, OIDC provider, magic links, SSO, and more with a single line of code.

Type-safe by default

Full TypeScript support with inferred types across your server and client — no type casting needed.

Multiple databases

Native adapters for Drizzle, Prisma, MongoDB, SQLite, PostgreSQL, and MySQL.

30+ OAuth providers

Built-in support for Google, GitHub, Apple, Discord, and dozens more social providers.

Enterprise ready

Multi-tenant organizations, SCIM provisioning, SAML SSO, and OIDC provider support.

Get started in 5 minutes

1

Install Better Auth

npm install better-auth
2

Create your auth instance

auth.ts
import { betterAuth } from "better-auth";

export const auth = betterAuth({
  database: /* your database connection */,
  emailAndPassword: { enabled: true },
});
3

Mount the handler

app/api/auth/[...all]/route.ts
import { auth } from "@/lib/auth";
import { toNextJsHandler } from "better-auth/next-js";

export const { POST, GET } = toNextJsHandler(auth);
4

Create a client

lib/auth-client.ts
import { createAuthClient } from "better-auth/react";

export const authClient = createAuthClient();

Follow the full installation guide

Get step-by-step instructions including database setup, CLI migration, and framework-specific configuration.

Build docs developers (and LLMs) love