
Auth Patterns
This walks you through the most common Next.js authentication patterns, with a heavy focus on NextAuth.js v5 (Auth.js). You get working examples for middleware protection, server and client session handling, role-based access control, and the difference between JWT and database sessions. It covers the practical stuff like protecting routes, building sign-in buttons as server actions, and extending session types for custom user data. The code snippets are complete enough to actually use. If you're setting up auth in a Next.js app and want to see the modern patterns side by side, this is a solid reference that'll save you from hunting through docs.
- skills.sh installs
- 182
- GitHub stars
- 3.7K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add davepoon/buildwithclaude --skill auth-patterns --agent claude-codeInstalls into .claude/skills of the current project.
Files
Authentication Patterns in Next.js
Overview
Next.js supports multiple authentication strategies. This skill covers common patterns including NextAuth.js (Auth.js), middleware-based protection, and session management.
Authentication Libraries
| Library | Best For |
|---|---|
| NextAuth.js (Auth.js) | Full-featured auth with providers |
| Clerk | Managed auth service |
| Lucia | Lightweight, flexible auth |
| Supabase Auth | Supabase ecosystem |
| Custom JWT | Full control |
NextAuth.js v5 Setup
Installation
npm install next-auth@beta
Configuration
// auth.ts
import NextAuth from 'next-auth'
import GitHub from 'next-auth/providers/github'
import Credentials from 'next-auth/providers/credentials'
Sponsors
Details
- Repository
- github.com/davepoon/buildwithclaude
- Categories
- Frontend Development, Backend & APIs, Security
- First seen
- Jun 3, 2026