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-code

Installs 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

LibraryBest For
NextAuth.js (Auth.js)Full-featured auth with providers
ClerkManaged auth service
LuciaLightweight, flexible auth
Supabase AuthSupabase ecosystem
Custom JWTFull 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

More from davepoon/buildwithclaude

All 6
1zhylq avatarzhy-wechat-writingzhylq/yuan-skillsUse when generating a complete WeChat article from a topic, with optional source research, evidence tracking, illustration, HTML conversion, and draft-box publi181skills.sh installs
2cinience avataralicloud-network-esacinience/alicloud-skillsManage Alibaba Cloud ESA — deploy HTML/static sites via Pages, manage Edge Routines (ER) for serverless edge functions, use Edge KV for distributed key-value st180skills.sh installs
3curiouslearner avatarreport-generatorcuriouslearner/devkitGenerate professional markdown and HTML reports from data with charts, tables, and analysis.180skills.sh installs
4astronomer avatarinitastronomer/agentsInitialize warehouse schema discovery. Generates .astro/warehouse.md with all table metadata for instant lookups. Run once per project, refresh when schema chan176skills.sh installs
5eyadsibai avatarcontent-writingeyadsibai/ltkUse when "writing articles", "blog posts", "content creation", "research writing", "technical writing", or asking about "outlining", "citations", "improving hoo175skills.sh installs
6xy121718 avatarbaoyu-infographicxy121718/baoyu-skillsGenerates professional infographics with 21 layout types and 20 visual styles. Analyzes content, recommends layout×style combinations, and generates publication175skills.sh installs