Skip to content

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.

ModelSource
sonnetpack: auth
Full Reference

┏━ 🔧 authjs ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Use when implementing authentication with Auth… ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

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+.

ItemValue
Current Versionv5 (beta: next-auth@beta)
Installnpm install next-auth@beta
Docshttps://authjs.dev
Min Next.js14.0+
Required env varAUTH_SECRET (run openssl rand -base64 32)
Session strategyJWT (default) or database
Provider env patternAUTH_GITHUB_ID / AUTH_GITHUB_SECRET (auto-detected)
I want to…File
Set up Auth.js in Next.js, SvelteKit, or Expressreference/setup.md
Configure OAuth, credentials, and magic link providersreference/providers.md
Access session server-side and client-side; use JWT vs database strategy; write callbacksreference/session.md
Protect routes with middleware or handle edge runtime split configreference/middleware.md
Set up Prisma, Drizzle, or Supabase adapterreference/database-adapters.md
Extend TypeScript types for session and JWTreference/typescript.md
Migrate from NextAuth v4 to Auth.js v5reference/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.