authjs
Use when implementing authentication with Auth.js (NextAuth.js) — OAuth providers, credentials, session management, or database adapters. Also use when upgrading from NextAuth v4 to Auth.js v5 or debugging auth callback issues.
| Model | Source |
|---|---|
| sonnet | pack: auth |
Full Reference
┏━ 🔧 authjs ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Use when implementing authentication with Auth… ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Auth.js (NextAuth.js v5)
Section titled “Auth.js (NextAuth.js v5)”Auth.js v5 (beta: next-auth@beta) is the universal auth library for Next.js, SvelteKit, and Express. It replaces the v4 getServerSession(authOptions) pattern with a single auth() function that works across Server Components, Route Handlers, Server Actions, and middleware. Requires Next.js 14+.
Quick Reference
Section titled “Quick Reference”| Item | Value |
|---|---|
| Current Version | v5 (beta: next-auth@beta) |
| Install | npm install next-auth@beta |
| Docs | https://authjs.dev |
| Min Next.js | 14.0+ |
| Required env var | AUTH_SECRET (run openssl rand -base64 32) |
| Session strategy | JWT (default) or database |
| Provider env pattern | AUTH_GITHUB_ID / AUTH_GITHUB_SECRET (auto-detected) |
Reference Index
Section titled “Reference Index”| I want to… | File |
|---|---|
| Set up Auth.js in Next.js, SvelteKit, or Express | reference/setup.md |
| Configure OAuth, credentials, and magic link providers | reference/providers.md |
| Access session server-side and client-side; use JWT vs database strategy; write callbacks | reference/session.md |
| Protect routes with middleware or handle edge runtime split config | reference/middleware.md |
| Set up Prisma, Drizzle, or Supabase adapter | reference/database-adapters.md |
| Extend TypeScript types for session and JWT | reference/typescript.md |
| Migrate from NextAuth v4 to Auth.js v5 | reference/v4-migration.md |
Usage: Read the reference file matching your current task from the index above. Each file is self-contained with code examples and inline gotchas.