wsimmonds/claude-nextjs-skills/nextjs-app-router-fundamentals
Claude Code and agent skill by wsimmonds/claude-nextjs-skills
- community
Checking that the SKILL.md file is still in the repository.
Guide for working with Next.js App Router (Next.js 13+). Use when migrating from Pages Router to App Router, creating layouts, implementing routing, handling metadata, or building Next.js 13+ applications. Activates for App Router migration, layout creation, routing patterns, or Next.js 13+ development tasks.
Install
npx vskill@latest install wsimmonds/claude-nextjs-skills/nextjs-app-router-fundamentalsSKILL.md
Next.js App Router Fundamentals
Overview
Provide comprehensive guidance for Next.js App Router (Next.js 13+), covering migration from Pages Router, file-based routing conventions, layouts, metadata handling, and modern Next.js patterns.
TypeScript: NEVER Use any Type
CRITICAL RULE: This codebase has @typescript-eslint/no-explicit-any enabled. Using any will cause build failures.
❌ WRONG:
✅ CORRECT:
Common Next.js Type Patterns
When to Use This Skill
Use this skill when:
- Migrating from Pages Router (
pages/directory) to App Router (app/directory) - Creating Next.js 13+ applications from scratch
- Working with layouts, templates, and nested routing
- Implementing metadata and SEO optimizations
- Building with App Router routing conventions
- Handling route groups, parallel routes, or intercepting routes basics
Core Concepts
App Router vs Pages Router
Pages Router (Legacy - Next.js 12 and earlier):
App Router (Modern - Next.js 13+):
File Conventions
Special Files in App Router:
layout.tsx- Shared UI for a segment and its children (preserves state, doesn't re-render)page.tsx- Unique UI for a route, makes route publicly accessibleloading.tsx- Loading UI with React Suspenseerror.tsx- Error UI with Error Boundariesnot-found.tsx- 404 UItemplate.tsx- Similar to layout but re-renders on navigationroute.ts- API endpoints (Route Handlers)
Colocation:
- Components, tests, and other files can be colocated in
app/ - Only
page.tsxandroute.tsfiles create public routes - Other files (components, utils, tests) are NOT routable
Migration Guide: Pages Router to App Router
Step 1: Understand the Current Structure
Examine existing Pages Router setup:
- Read
pages/directory structure - Identify
_app.tsx- handles global state, layouts, providers - Identify
_document.tsx- customizes HTML structure - Note metadata usage (
next/head,<Head>component) - List all routes and dynamic segments
Step 2: Create Root Layout
Create app/layout.tsx - REQUIRED for all App Router applications:
Migration Notes:
- Move
_document.tsxHTML structure tolayout.tsx - Move
_app.tsxglobal providers/wrappers tolayout.tsx - Convert
<Head>metadata tometadataexport - The root layout MUST include
<html>and<body>tags
Step 3: Migrate Pages to Routes
Simple Page Migration:
Nested Route Migration:
Step 4: Update Navigation
Replace anchor tags with Next.js Link:
Step 5: Clean Up Pages Directory
After migration:
- Remove all page files from
pages/directory - Keep
pages/api/if you're not migrating API routes yet - Remove
_app.tsxand_document.tsx(functionality moved to layout) - Optionally delete empty
pages/directory
Metadata Handling
Static Metadata
Dynamic Metadata
Layouts and Nesting
Creating Nested Layouts
Layout Behavior:
- Layouts preserve state across navigation
- Layouts don't re-render on route changes
- Parent layouts wrap child layouts
- Root layout is required and wraps entire app
Routing Patterns
Dynamic Routes
Catch-All Routes
Optional Catch-All
Route Groups
Group routes without affecting URL:
Common Migration Pitfalls
Pitfall 1: Forgetting Root Layout HTML Tags
Wrong:
Correct:
Pitfall 2: Using next/head in App Router
Wrong:
Correct:
Pitfall 3: Not Removing Pages Directory
After migrating routes, remove the old pages/ directory files to avoid confusion. The build will fail if you have conflicting routes.
Pitfall 4: Missing page.tsx Files
Routes are NOT accessible without a page.tsx file. Layouts alone don't create routes.
Pitfall 5: Incorrect Link Usage
Wrong:
Correct:
Server Components vs Client Components
Default: Server Components
All components in app/ are Server Components by default:
Benefits:
- Can use async/await directly
- Direct database/API access
- Zero client-side JavaScript
- Automatic code splitting
Client Components
Use 'use client' directive when you need:
- Interactive elements (onClick, onChange, etc.)
- React hooks (useState, useEffect, useContext, etc.)
- Browser APIs (window, localStorage, etc.)
- Event listeners
Data Fetching Patterns
Server Component Data Fetching
Parallel Data Fetching
Static Site Generation with generateStaticParams
Overview
generateStaticParams is the App Router equivalent of getStaticPaths from the Pages Router. It generates static pages at build time for dynamic routes.
Basic Usage
Key Points:
- Returns an array of objects with route parameter keys
- Each object represents one page to pre-render at build time
- Function must be exported and named
generateStaticParams - Works ONLY in Server Components (no
'use client'directive) - Replaces Pages Router's
getStaticPaths
Fetching Data for Static Params
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingnextjs-app-router-fundamentals/SKILL.md
Popularity
- Repository stars
- 73
- Repository forks
- 9
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 16 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/wsimmonds/claude-nextjs-skills/nextjs-app-router-fundamentals)