Building Next.js applications, implementing SSR/SSG

Next.js App Router Patterns

by wshobson · MIT license · ★ 39,857 on GitHub · updated Sep 21

Next.js App Router Patterns cover

Master Next.js 14+ App Router with Server Components, streaming, parallel routes, and advanced data fetching. Use when building Next.js applications, implementing SSR/SSG, or optimizing React Server Components.

---
name: nextjs-app-router-patterns
description: Master Next.js 14+ App Router with Server Components, streaming, parallel routes, and advanced data fetching. Use when building Next.js applications, implementing SSR/SSG, or optimizing React Server Components.
---

# Next.js App Router Patterns

Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

## When to Use This Skill

- Building new Next.js applications with App Router
- Migrating from Pages Router to App Router
- Implementing Server Components and streaming
- Setting up parallel and intercepting routes
- Optimizing data fetching and caching
- Building full-stack features with Server Actions

Overview

Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

Manual install (npx, ZIP)
Claude Codenpx skills add wshobson/agents --skill nextjs-app-router-patterns -g -a claude-code
Claude Code (manual)mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/wshobson/agents/tar.gz/4236bb91f839 \ | tar -xz -C ~/.claude/skills --strip-components=4 agents-4236bb91f839/plugins/frontend-mobile-development/skills/nextjs-app-router-patterns
Windows (PowerShell)New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/d734e81953b20e94af5b/nextjs-app-router-patterns.zip" -OutFile "$env:TEMP\nextjs-app-router-patterns.zip"; Expand-Archive "$env:TEMP\nextjs-app-router-patterns.zip" -DestinationPath "$HOME\.claude\skills" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md3.6 KB
  • references/1 file · 9.7 KB
Read the files here
wshobson/4236bb92 files
SKILL.md
Show the full text115 lines

Next.js App Router Patterns

Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

When to Use This Skill

  • Building new Next.js applications with App Router
  • Migrating from Pages Router to App Router
  • Implementing Server Components and streaming
  • Setting up parallel and intercepting routes
  • Optimizing data fetching and caching
  • Building full-stack features with Server Actions

Core Concepts

1. Rendering Modes
Mode Where When to Use
Server Components Server only Data fetching, heavy computation, secrets
Client Components Browser Interactivity, hooks, browser APIs
Static Build time Content that rarely changes
Dynamic Request time Personalized or real-time data
Streaming Progressive Large pages, slow data sources
2. File Conventions
app/
├── layout.tsx       # Shared UI wrapper
├── page.tsx         # Route UI
├── loading.tsx      # Loading UI (Suspense)
├── error.tsx        # Error boundary
├── not-found.tsx    # 404 UI
├── route.ts         # API endpoint
├── template.tsx     # Re-mounted layout
├── default.tsx      # Parallel route fallback
└── opengraph-image.tsx  # OG image generation

Quick Start

// app/layout.tsx
import { Inter } from 'next/font/google'
import { Providers } from './providers'

const inter = Inter({ subsets: ['latin'] })

export const metadata = {
  title: { default: 'My App', template: '%s | My App' },
  description: 'Built with Next.js App Router',
}

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body className={inter.className}>
        <Providers>{children}</Providers>
      </body>
    </html>
  )
}

// app/page.tsx - Server Component by default
async function getProducts() {
  const res = await fetch('https://api.example.com/products', {
    next: { revalidate: 3600 }, // ISR: revalidate every hour
  })
  return res.json()
}

export default async function HomePage() {
  const products = await getProducts()

  return (
    <main>
      <h1>Products</h1>
      <ProductGrid products={products} />
    </main>
  )
}

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Best Practices

Do's
  • Start with Server Components - Add 'use client' only when needed
  • Colocate data fetching - Fetch data where it's used
  • Use Suspense boundaries - Enable streaming for slow data
  • Leverage parallel routes - Independent loading states
  • Use Server Actions - For mutations with progressive enhancement
Don'ts
  • Don't pass serializable data - Server → Client boundary limitations
  • Don't use hooks in Server Components - No useState, useEffect
  • Don't fetch in Client Components - Use Server Components or React Query
  • Don't over-nest layouts - Each layout adds to the component tree
  • Don't ignore loading states - Always provide loading.tsx or Suspense
1---
2name: nextjs-app-router-patterns
3description: Master Next.js 14+ App Router with Server Components, streaming, parallel routes, and advanced data fetching. Use when building Next.js applications, implementing SSR/SSG, or optimizing React Server Components.
4---
5 
6# Next.js App Router Patterns
7 
8Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.
9 
10## When to Use This Skill
11 
12- Building new Next.js applications with App Router
13- Migrating from Pages Router to App Router
14- Implementing Server Components and streaming
15- Setting up parallel and intercepting routes
16- Optimizing data fetching and caching
17- Building full-stack features with Server Actions
18 
19## Core Concepts
20 
21### 1. Rendering Modes
22 
23| Mode | Where | When to Use |
24| --------------------- | ------------ | ----------------------------------------- |
25| **Server Components** | Server only | Data fetching, heavy computation, secrets |
26| **Client Components** | Browser | Interactivity, hooks, browser APIs |
27| **Static** | Build time | Content that rarely changes |
28| **Dynamic** | Request time | Personalized or real-time data |
29| **Streaming** | Progressive | Large pages, slow data sources |
30 
31### 2. File Conventions
32 
33```
34app/
35├── layout.tsx # Shared UI wrapper
36├── page.tsx # Route UI
37├── loading.tsx # Loading UI (Suspense)
38├── error.tsx # Error boundary
39├── not-found.tsx # 404 UI
40├── route.ts # API endpoint
41├── template.tsx # Re-mounted layout
42├── default.tsx # Parallel route fallback
43└── opengraph-image.tsx # OG image generation
44```
45 
46## Quick Start
47 
48```typescript
49// app/layout.tsx
50import { Inter } from 'next/font/google'
51import { Providers } from './providers'
52 
53const inter = Inter({ subsets: ['latin'] })
54 
55export const metadata = {
56 title: { default: 'My App', template: '%s | My App' },
57 description: 'Built with Next.js App Router',
58}
59 
60export default function RootLayout({
61 children,
62}: {
63 children: React.ReactNode
64}) {
65 return (
66 <html lang="en" suppressHydrationWarning>
67 <body className={inter.className}>
68 <Providers>{children}</Providers>
69 </body>
70 </html>
71 )
72}
73 
74// app/page.tsx - Server Component by default
75async function getProducts() {
76 const res = await fetch('https://api.example.com/products', {
77 next: { revalidate: 3600 }, // ISR: revalidate every hour
78 })
79 return res.json()
80}
81 
82export default async function HomePage() {
83 const products = await getProducts()
84 
85 return (
86 <main>
87 <h1>Products</h1>
88 <ProductGrid products={products} />
89 </main>
90 )
91}
92```
93 
94## Detailed patterns and worked examples
95 
96Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
97 
98## Best Practices
99 
100### Do's
101 
102- **Start with Server Components** - Add 'use client' only when needed
103- **Colocate data fetching** - Fetch data where it's used
104- **Use Suspense boundaries** - Enable streaming for slow data
105- **Leverage parallel routes** - Independent loading states
106- **Use Server Actions** - For mutations with progressive enhancement
107 
108### Don'ts
109 
110- **Don't pass serializable data** - Server → Client boundary limitations
111- **Don't use hooks in Server Components** - No useState, useEffect
112- **Don't fetch in Client Components** - Use Server Components or React Query
113- **Don't over-nest layouts** - Each layout adds to the component tree
114- **Don't ignore loading states** - Always provide loading.tsx or Suspense
115 
View all files on GitHub →

Details

Updated
Sep 21, 2026
License
MIT
Stars on the repo
★ 39,857
Checked
Source
wshobson/agents ↗
Creator
wshobson · 179 listings
View creator

Similar skills

See all →
SkillDoing ANY task involving Supabasesupabase/agent-skills · by supabaseUse when doing ANY task involving Supabase. Triggers: Supabase products (Database, Auth, Edge Functions, Realtime, Storage, Vectors, Cron, Queues); client libraries and SSR integrations (supabase-js, @supabase/ssr) in Next.js, React, SvelteKit, Astro, Remix; auth issues (login, logout, sessions, JWT, cookies, getSession, getUser, getClaims, RLS); Supabase CLI or MCP server; schema changes, migrations, declarative schemas, security audits, Postgres extensions (pg_graphql, pg_cron, pg_vector); debugging and troubleshooting errors or unexpected behavior on Supabase projects (HTTP errors, Postgres errors, RLS surprises, permission denied, schema cache issues, timeouts, Edge Function crashes, Realtime drops, Storage failures) and reading or querying logs (Logs Explorer, ClickHouse).★ 2.7k GitHub starsPromptAct as a specialized front-end developer with expertiseNext.js Specialized Front-End Developerf/prompts.chat · by nedirbuAct as a specialized front-end developer with expertise in Next.js, focusing on building dynamic and efficient web applications.New listingSkillReviewing a specific inbound deal before closeDeal deskalirezarezvani/claude-skills · by alirezarezvaniUse when reviewing a specific inbound deal before close — when sales has asked for a discount that exceeds AE authority, when the customer has redlined the MSA, when per-deal economics (margin after discount, multi-year payment shape, indemnity exposure) need to be quantified, or when discount approval needs to be routed to a named human approver (Sales Director, VP Sales, CFO, CRO, General Counsel). Covers deal review, discount approval routing, per-deal margin scoring, deal exception handling, MSA redline triage, contract landmine detection (uncapped indemnity, MFN, perpetual license-back, missing DPA), and named-approver chain assembly. NEVER auto-approves — every output is a numeric scorecard plus a routing recommendation to a named human.★ 26.3k GitHub starsSkillGenerates complete, production-ready SaaS projectSAAS scaffolderalirezarezvani/claude-skills · by alirezarezvaniGenerates complete, production-ready SaaS project boilerplate including authentication, database schemas, billing integration, API routes, and a working dashboard using Next.js 14+ App Router, TypeScript, Tailwind CSS, shadcn/ui, Drizzle ORM, and Stripe. Use when the user wants to create a new SaaS app, start a subscription-based web project, scaffold a Next.js application, or mentions terms like starter template, boilerplate, new project, or wiring up auth and payments.★ 26.3k GitHub starsSkillBuilding React components, optimizing Next.js performanceSenior frontendalirezarezvani/claude-skills · by alirezarezvaniFrontend development skill for React, Next.js, TypeScript, and Tailwind CSS applications. Use when building React components, optimizing Next.js performance, analyzing bundle sizes, scaffolding frontend projects, implementing accessibility, or reviewing frontend code quality.★ 26.3k GitHub starsMCPBuilding command-line tools and terminal applicationsCLI developerVoltAgent/awesome-claude-code-subagents · by VoltAgentUse this agent when building command-line tools and terminal applications that require intuitive command design, cross-platform compatibility, and optimized developer experience.★ 25.2k GitHub stars

More from wshobson

SkillMaster C/.NET backend development patterns for buildingwshobson/agents · by wshobsonMaster C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.★ 39.9k GitHub starsSkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliancewshobson/agents · by wshobsonImplement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.★ 39.9k GitHub starsSkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Designwshobson/agents · by wshobsonMaster Material Design 3 and Jetpack Compose patterns for building native Android apps. Use when designing Android interfaces, implementing Compose UI, or following Google's Material Design guidelines.★ 39.9k GitHub starsSkillMigrate from AngularJS to Angular using hybrid modeAngular migrationwshobson/agents · by wshobsonMigrate from AngularJS to Angular using hybrid mode, incremental component rewriting, and dependency injection updates. Use when upgrading AngularJS applications, planning framework migrations, or modernizing legacy Angular code.★ 39.9k GitHub starsSkillUnderstand anti-reversing, obfuscationAnti reversing techniqueswshobson/agents · by wshobsonUnderstand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use this skill when analyzing malware evasion techniques, when implementing anti-debugging protections for CTF challenges, when reverse engineering packed binaries, or when building security research tools that need to detect virtualized environments.★ 39.9k GitHub starsSkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patternswshobson/agents · by wshobsonBuild production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs.★ 39.9k GitHub stars