This is a comprehensive reference for implementing Auth.js 5 (NextAuth.js) authentication in Next.js 15+ App Router apps. It covers the full setup from installing dependencies and configuring OAuth providers to protecting routes with middleware, securing Server Actions, and implementing role-based access control. You'd reach for this when wiring up GitHub or Google sign-in, protecting dashboard routes, or ensuring your Server Components and Actions actually check authentication before exposing data. The patterns are solid and production-focused, with proper TypeScript types and clear examples of common scenarios like protected dashboards and admin panels. It assumes you're comfortable with App Router conventions but need the Auth.js specifics spelled out.

skills.sh installs
3.9K
GitHub stars
369
last updated
Aug 21, 2026

Install

$ npx -y skills add giuseppe-trisciuoglio/developer-kit --skill nextjs-authentication --agent claude-code

Installs into .claude/skills of the current project.

Files

Next.js Authentication

Overview

Provides authentication implementation patterns for Next.js 15+ App Router using Auth.js 5 (NextAuth.js), covering the complete authentication lifecycle from initial setup to production-ready role-based access control implementations.

When to Use

  • Setting up Auth.js 5 from scratch or adding OAuth providers
  • Implementing protected routes with Middleware
  • Handling authentication in Server Components and Server Actions
  • Implementing role-based access control (RBAC)
  • Creating credential-based or OAuth sign-in/sign-out flows

Instructions

1. Install Dependencies

Install Auth.js v5 (beta) for Next.js App Router:

npm install next-auth@beta

2. Configure Environment Variables

Create .env.local with required variables:

# Required for Auth.js
AUTH_SECRET="your-secret-key-here"
AUTH_URL="http://localhost:3000"

# OAuth Providers (add as needed)
GITHUB_ID="your-github-client-id"
GITHUB_SECRET="your-github-client-secret"
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"

Generate AUTH_SECRET with:

openssl rand -base64 32

Sponsors

Details

Repository
github.com/giuseppe-trisciuoglio/developer-kit
Categories
Frontend Development, Backend & APIs, Security
First seen
May 16, 2026

More from giuseppe-trisciuoglio/developer-kit

All 102
1giuseppe-trisciuoglio avatarnextjs-deploymentgiuseppe-trisciuoglio/developer-kitProvides comprehensive patterns for deploying Next.js applications to production. Use when configuring Docker containers, setting up GitHub Actions CI/CD pipeli3.8Kskills.sh installs
2langgenius avatarfrontend-testinglanggenius/difyUse when writing or changing Vitest or React Testing Library tests under `web/` or `packages/dify-ui/`, or when the user explicitly requests frontend test strat3.8Kskills.sh installs
3dotnet avatarauthor-componentdotnet/skillsCreate or review Blazor components (.razor files) with correct architecture. USE FOR: writing new Blazor components that do NOT involve JavaScript interop, impl3.8Kskills.sh installs
4nexu-io avatarpptx-html-fidelity-auditnexu-io/open-designAudit a python-pptx export against its source HTML deck, identify layout/content drift (footer overflow, cropped content, missing italic/em, lost styling, off-r3.3Kskills.sh installs
5vercel-labs avatarreact-nativevercel-labs/json-renderReact Native renderer for json-render that turns JSON specs into native mobile UIs. Use when working with @json-render/react-native, building React Native UIs f3.3Kskills.sh installs
6onmax avatarnuxt-contentonmax/nuxt-skillsBuild typed, content-driven Nuxt applications with @nuxt/content. Use when working with content.config.ts, collections, queryCollection, Markdown or MDC renderi2.9Kskills.sh installs