nextjs-app-router

Guide Next.js App Router implementation with routing, layouts, and data flows.

4|2|Updated Jan 17, 2026
One-click install
npx skills add https://github.com/jawwad-ali/claude-code-skills --skill nextjs-app-router-jawwad-ali
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-app-router
Source: https://github.com/jawwad-ali/claude-code-skills/tree/main/.claude/skills/nextjs-app-router
Command: npx skills add https://github.com/jawwad-ali/claude-code-skills --skill nextjs-app-router-jawwad-ali

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill provides comprehensive guidance for implementing Next.js App Router applications, including how to structure app/ directories, distinguish server and client components, and apply production patterns.

Core Features & Use Cases

  • File-Based Routing: The App Router uses folders for routes and files for UI components.
  • Server Components vs Client Components: Clarifies server default and how to opt into client-side interactivity with 'use client'.
  • Data Fetching & Routing: Covers server actions, caches, dynamic routes, and route handlers.
  • Layouts, Loading, and Error States: Explains nested layouts, skeleton loading, and error boundaries.
  • Metadata & Production Patterns: Demonstrates metadata usage and mandatory production patterns like loading.tsx and error.tsx.

Quick Start

Create a minimal Next.js App Router project with an app directory, a root layout, a sample page, loading.tsx, error.tsx, and a basic API route to demonstrate production patterns.

Frequently Asked Questions about nextjs-app-router

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure file-based routing in the Next.js App Router?

File-based routing in the Next.js App Router uses folders to define routes and specific files like page.tsx for UI components within the app directory. This structure enables nested layouts and dynamic routes for scalable applications.

What is the difference between server components and client components in Next.js?

Server components are the default in the Next.js app directory, fetching data securely on the server. You opt into client components for interactivity by adding the 'use client' directive to handle browser-side state and events.

How do I fetch data and handle caching with Next.js server components?

Data fetching in Next.js server components supports direct database queries and API calls with built-in caching. You can control data freshness using revalidation patterns and server actions to mutate data without creating separate API endpoints.

Do I need loading.tsx and error.tsx files for every route in Next.js?

Production Next.js patterns mandate loading.tsx for skeleton loading states and error.tsx for error boundaries. While not strictly required for every route, implementing them ensures graceful UI fallbacks during data fetching and runtime errors.

What's the best way to define metadata and layouts in a Next.js app directory?

Defining metadata in the Next.js app directory uses a static metadata object or generateMetadata function inside layout.tsx and page.tsx files. Nested layouts allow shared UI structures across routes while maintaining distinct metadata configurations.