New advertisers: 50% off your first month with code FIRSTMONTHSee slots

Complete Auth.js 5 setup for Next.js App Router, covering OAuth, route protection, and role-based access.

skills.sh installs
4K
GitHub stars
372
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers the full lifecycle: install, environment setup, auth config, middleware route guards, and sign-in/sign-out flows
  • Includes auth.ts, middleware.ts, and a typed session extension, with GitHub and Google OAuth providers and a credentials sign-in example
  • Enforces redirects for unauthenticated users on /dashboard, auth checks before Server Action mutations, and admin-only pages via unauthorized()
  • Designed for Next.js 15+ projects using the App Router with Server Components and Server Actions

Install

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

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

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

Details

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

More from giuseppe-trisciuoglio/developer-kit

All 95

Similar to Nextjs Authentication

More Backend & APIs