Features
- 50+ OAuth providers (Google, GitHub, Discord, etc.)
- Email/password, magic link, and WebAuthn support
- Framework adapters for Next.js, SvelteKit, Express, etc.
- Database adapters for Prisma, Drizzle, TypeORM, etc.
Pros
- Free and open-source with no vendor lock-in
- Extensive provider and database adapter ecosystem
- Framework-agnostic design (originally NextAuth.js)
Cons
- Configuration can be complex for custom auth flows
- Session management has gotchas across frameworks
- Documentation quality varies between adapters
Overview
Auth.js (formerly NextAuth.js) is an open-source authentication library that provides a complete authentication solution for web applications. It supports 50+ OAuth providers, email/passwordless authentication, and WebAuthn, with adapters for popular frameworks like Next.js, SvelteKit, Express, and Remix.
Auth.js handles session management, CSRF protection, and token rotation automatically. Its database adapter system supports Prisma, Drizzle, TypeORM, and many others, making it flexible enough to fit into most existing application architectures.
When to Use
Auth.js is the right choice when you want free, self-hosted authentication with OAuth providers, when you need a framework-agnostic auth solution, or when you want full control over your authentication data. For a hosted solution with more features, consider Clerk.
Getting Started
npm install next-auth
import NextAuth from "next-auth";
import GitHub from "next-auth/providers/github";
export const { handlers, auth } = NextAuth({
providers: [GitHub],
});