Nextjs App Router Patterns skill for Claude

Master Next.js 14+ App Router with Server Components, streaming, parallel routes, and advanced data fetching.

When Claude uses it

Use when building Next.js applications, implementing SSR/SSG, or optimizing React Server Components.

Nextjs App Router Patterns SKILL.md

The full skill file from wshobson/agents (MIT).

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

ModeWhereWhen to Use
Server ComponentsServer onlyData fetching, heavy computation, secrets
Client ComponentsBrowserInteractivity, hooks, browser APIs
StaticBuild timeContent that rarely changes
DynamicRequest timePersonalized or real-time data
StreamingProgressiveLarge 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

How to install Nextjs App Router Patterns

Claude Code

Copy the skill into your personal skills folder (or into .claude/skills/ inside a project):

npx degit wshobson/agents/plugins/frontend-mobile-development/skills/nextjs-app-router-patterns#main ~/.claude/skills/nextjs-app-router-patterns

Codex

npx degit wshobson/agents/plugins/frontend-mobile-development/skills/nextjs-app-router-patterns#main ~/.codex/skills/nextjs-app-router-patterns

Claude.ai and Claude Desktop

Download the skill folder from GitHub, zip it, and upload it under Settings → Capabilities → Skills.

Frequently asked questions

+What does the Nextjs App Router Patterns skill do?

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.

+How do I install Nextjs App Router Patterns in Claude Code?

Copy the skill folder into ~/.claude/skills/nextjs-app-router-patterns, for example with "npx degit wshobson/agents/plugins/frontend-mobile-development/skills/nextjs-app-router-patterns#main ~/.claude/skills/nextjs-app-router-patterns". Claude Code loads it automatically and uses it when a task matches.

+Does Nextjs App Router Patterns work with ChatGPT or Codex?

Yes. Nextjs App Router Patterns uses the open SKILL.md format. In Codex, put the folder in ~/.codex/skills/nextjs-app-router-patterns. In Claude.ai, zip the folder and upload it under Settings → Capabilities → Skills.

+Is Nextjs App Router Patterns free?

Nextjs App Router Patterns is published on GitHub by wshobson under the MIT license, which allows free use.

Related software development skills

  1. Code Review

    Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes: Standards (does the code follow this repo's…

    mattpocock/skills★ 327k
  2. Using Agent Skills

    Discovers and invokes agent skills. Use when starting a session, or when you need to decide which skill or workflow applies to the piece of…

    addyosmani/agent-skills★ 119k
  3. Build

    Fully automate a coding task with make-plan, do, and babysit.

    thedotmack/claude-mem★ 118k
  4. Nodejs Backend Patterns

    Build production-ready Node.js backend services with Express/Fastify, implementing middleware patterns, error handling, authentication,…

    wshobson/agents★ 43k
  5. Nx Workspace Patterns

    Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or…

    wshobson/agents★ 43k
  6. Openapi Spec Generation

    Generate and maintain OpenAPI 3.1 specifications from code, design-first specs, and validation patterns.

    wshobson/agents★ 43k
  7. Parallel Debugging

    Debug complex issues using competing hypotheses with parallel investigation, evidence collection, and root cause arbitration.

    wshobson/agents★ 43k
  8. Preference Optimization

    Align a fine-tuned model with preference data using DPO, ORPO, KTO, or SimPO.

    wshobson/agents★ 43k
  9. Projection Patterns

    Build read models and projections from event streams. Use when implementing CQRS read sides, building materialized views, or optimizing…

    wshobson/agents★ 43k

See all software development skills →

More skills from wshobson

  1. Nft Standards

    Implement NFT standards (ERC-721, ERC-1155) with proper metadata handling, minting strategies, and marketplace integration.

    wshobson/agents★ 43k

All skills by wshobson →

Give your whole team an AI agent with skills

Cody runs managed AI agents your team can message in Slack, Teams, WhatsApp and the web, with 50+ business integrations, scheduled tasks and memory. No terminal required.