nextjs-app-router-patterns

Implements Next.js App Router patterns for Server Components, streaming, and data fetching.

Updated Sep 1, 2021
One-click install
npx skills add https://github.com/WP-Coaching/pellegrims.coach --skill nextjs-app-router-patterns-wp-coaching
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-app-router-patterns
Source: https://github.com/WP-Coaching/pellegrims.coach/tree/main/.agents/skills/nextjs-app-router-patterns
Command: npx skills add https://github.com/WP-Coaching/pellegrims.coach --skill nextjs-app-router-patterns-wp-coaching

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building modern Next.js applications requires navigating complex decisions around Server vs Client Components, caching strategies, streaming, and routing conventions, and mistakes lead to hydration errors, poor performance, or broken data flows. ## Core Features & Use Cases - Rendering Patterns: Provides working code for Server Components, Client Components, static generation, dynamic rendering, and Suspense-based streaming. - Advanced Routing: Covers parallel routes, intercepting routes for modals, route handlers for APIs, and file conventions like loading.tsx and error.tsx. - Data & Mutations: Demonstrates fetch caching with revalidation tags, Server Actions for form mutations, and dynamic metadata generation for SEO. - Use Case: When building a product dashboard that needs independent loading states for analytics and team panels, apply the parallel routes pattern with slot-level loading.tsx files. ## Quick Start Ask the assistant to scaffold a Next.js App Router page with Server Components, Suspense streaming, and a Server Action for form submission.

Frequently Asked Questions about nextjs-app-router-patterns

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

FAQPage Schema
How do I use Server Components in Next.js App Router?

Server Components are the default in the App Router, so any component without a 'use client' directive runs on the server. Fetch data directly inside async components and pass serializable props down to Client Components for interactivity.

How to revalidate cached data in Next.js fetch requests?

Use the next option in fetch with revalidate for time-based ISR or tags for on-demand invalidation. Call revalidateTag or revalidatePath from next/cache inside a Server Action after a mutation to refresh stale data.

When should I use 'use client' in Next.js?

Add 'use client' only when a component needs interactivity such as useState, useEffect, event handlers, or browser APIs. Keep components as Server Components by default and push client boundaries as far down the tree as possible.

How do parallel routes work in Next.js App Router?

Parallel routes use named slots like @analytics and @team folders that render simultaneously in the same layout. Each slot gets its own loading.tsx and error.tsx, enabling independent streaming and error boundaries per panel.

Why can't I use hooks in Next.js Server Components?

Server Components render only on the server and never hydrate in the browser, so React hooks like useState and useEffect have no runtime to execute in. Move stateful logic into a child Client Component marked with 'use client'.

What are the limitations of passing props from Server to Client Components?

Props crossing the server-client boundary must be serializable, so functions, class instances, and Dates in some cases cannot be passed directly. Pass plain objects, strings, numbers, and arrays, or use Server Actions for callable behavior.