Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Collection of 146 agent skills across 72 plugins for full-stack development, orchestration, and automation.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: nextjs-app-router-patterns3description: 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---56# Next.js App Router Patterns78Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.910## When to Use This Skill1112- Building new Next.js applications with App Router13- Migrating from Pages Router to App Router14- Implementing Server Components and streaming15- Setting up parallel and intercepting routes16- Optimizing data fetching and caching17- Building full-stack features with Server Actions1819## Core Concepts2021### 1. Rendering Modes2223| 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 |3031### 2. File Conventions3233```34app/35├── layout.tsx # Shared UI wrapper36├── page.tsx # Route UI37├── loading.tsx # Loading UI (Suspense)38├── error.tsx # Error boundary39├── not-found.tsx # 404 UI40├── route.ts # API endpoint41├── template.tsx # Re-mounted layout42├── default.tsx # Parallel route fallback43└── opengraph-image.tsx # OG image generation44```4546## Quick Start4748```typescript49// app/layout.tsx50import { Inter } from 'next/font/google'51import { Providers } from './providers'5253const inter = Inter({ subsets: ['latin'] })5455export const metadata = {56title: { default: 'My App', template: '%s | My App' },57description: 'Built with Next.js App Router',58}5960export default function RootLayout({61children,62}: {63children: React.ReactNode64}) {65return (66<html lang="en" suppressHydrationWarning>67<body className={inter.className}>68<Providers>{children}</Providers>69</body>70</html>71)72}7374// app/page.tsx - Server Component by default75async function getProducts() {76const res = await fetch('https://api.example.com/products', {77next: { revalidate: 3600 }, // ISR: revalidate every hour78})79return res.json()80}8182export default async function HomePage() {83const products = await getProducts()8485return (86<main>87<h1>Products</h1>88<ProductGrid products={products} />89</main>90)91}92```9394## Detailed patterns and worked examples9596Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.9798## Best Practices99100### Do's101102- **Start with Server Components** - Add 'use client' only when needed103- **Colocate data fetching** - Fetch data where it's used104- **Use Suspense boundaries** - Enable streaming for slow data105- **Leverage parallel routes** - Independent loading states106- **Use Server Actions** - For mutations with progressive enhancement107108### Don'ts109110- **Don't pass serializable data** - Server → Client boundary limitations111- **Don't use hooks in Server Components** - No useState, useEffect112- **Don't fetch in Client Components** - Use Server Components or React Query113- **Don't over-nest layouts** - Each layout adds to the component tree114- **Don't ignore loading states** - Always provide loading.tsx or Suspense115