Next.js Idioms and Patterns

Enforces idiomatic Next.js App Router patterns for Server Components, caching, and boundaries.

150|48|Updated Jan 24, 2026
One-click install
npx skills add https://github.com/irahardianto/awesome-agv --skill next-js-idioms-and-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Next.js Idioms and Patterns
Source: https://github.com/irahardianto/awesome-agv/tree/main/.agents/skills/nextjs-idioms
Command: npx skills add https://github.com/irahardianto/awesome-agv --skill next-js-idioms-and-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Next.js codebases often accumulate non-idiomatic patterns that hurt performance, reliability, and maintainability, especially around the App Router, Server Components, and caching.

Core Features & Use Cases

  • App Router defaults: enforce Server-first composition with correct layout and route-segment boundaries (loading/error/not-found).
  • Server-first data access: fetch directly in Server Components and use Server Actions for mutations with cache invalidation via revalidatePath/revalidateTag.
  • Production-grade performance and SEO: apply static vs dynamic rendering, streaming with Suspense, next/image usage, and metadata APIs for per-page SEO.
  • Anti-pattern avoidance: prevent common mistakes like indiscriminate 'use client', fetching in layout, sequential awaits in Server Components, and legacy getServerSideProps/getStaticProps.

Quick Start

Use this skill to rewrite your Next.js App Router implementation so data fetching, mutations, error boundaries, streaming, caching, image usage, and metadata follow idiomatic Next.js (14+) patterns.

Frequently Asked Questions about Next.js Idioms and Patterns

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

FAQPage Schema
How do I structure loading and error boundaries in the Next.js App Router?

Next.js App Router boundaries require dedicated loading, error, and not-found files within route segments to handle streaming and failures. Using these file conventions ensures proper Suspense wrapping and recoverable error states without breaking the entire route layout.

When should I use Server Components vs Client Components in Next.js?

Use Server Components by default for data fetching and rendering, restricting Client Components to interactivity. Indiscriminate use of the 'use client' directive prevents server-first data access and causes performance regressions in your Next.js application.

How do I invalidate the cache after a Server Action mutation in Next.js?

Invalidate the Next.js cache after Server Action mutations by calling revalidatePath or revalidateTag. This ensures your data freshness without falling back to legacy fetching methods or manual cache clearing.

How do I migrate from getServerSideProps to the Next.js App Router?

Migrating from getServerSideProps and getStaticProps involves moving data fetching directly into Server Components and using dynamic rendering. The Next.js App Router replaces these legacy functions with server-side fetching and streaming via Suspense.

What is the best way to handle SEO metadata in Next.js App Router?

Handle SEO metadata in Next.js App Router by using the metadata APIs for per-page configuration. This replaces the legacy Head component and allows dynamic generation of title and meta tags directly from Server Components.

Why are sequential awaits a problem in Next.js Server Components?

Sequential awaits in Next.js Server Components block rendering and delay the response time. Fetching data in parallel prevents these waterfalls, improving performance and allowing the route to stream effectively with Suspense.