nextjs-patterns

Establish Next.js App Router and Server Component patterns for full-stack React applications.

364|53|Updated May 9, 2026
One-click install
npx skills add https://github.com/cosmicstack-labs/mercury-agent-skills --skill nextjs-patterns-cosmicstack-labs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-patterns
Source: https://github.com/cosmicstack-labs/mercury-agent-skills/tree/main/categories/frontend/nextjs-patterns
Command: npx skills add https://github.com/cosmicstack-labs/mercury-agent-skills --skill nextjs-patterns-cosmicstack-labs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you avoid common Next.js App Router and Server Component pitfalls while building production-grade full-stack React applications with predictable performance and maintainable architecture.

Core Features & Use Cases

  • App Router + Server Components Architecture: Use App Router conventions, Server Components by default, and correct server/client composition to minimize bundle size and keep sensitive logic on the server.
  • Data Fetching + Caching/Revalidation Strategies: Apply server-side fetching patterns, parallel data loading, and explicit caching/revalidation using revalidate, tags, paths, and dynamic/static controls.
  • Streaming, Route Handlers, and Operational Robustness: Implement Suspense-based streaming, API route handlers, route groups, middleware-based auth protection, and loading/error/not-found UI states.

Quick Start

Ask for a production-ready Next.js App Router architecture using Server Components, streaming with Suspense, and correct caching/revalidation for a dashboard page with API route handlers.

Frequently Asked Questions about nextjs-patterns

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

FAQPage Schema
How do I structure Next.js App Router Server and Client Components safely?

To structure Next.js App Router components safely, use Server Components by default and establish correct server/client boundaries. This composition minimizes client bundle size and keeps sensitive logic securely on the server.

What's the best way to implement data fetching and caching in Next.js App Router?

The best way to implement data fetching and caching in Next.js is applying server-side fetching patterns with explicit caching controls. Use revalidate, tags, paths, and dynamic/static settings for predictable performance.

How do I add Suspense streaming and loading states to a Next.js route?

To add Suspense streaming and loading states in Next.js, implement Suspense-based streaming alongside route handlers. This approach provides operational robustness and ensures UI states render progressively during data loading.

Does Next.js App Router support middleware-based auth protection and route groups?

Yes, Next.js App Router supports middleware-based auth protection and route groups. These conventions allow you to secure routes and organize your application architecture logically for production reliability.

Why are my Next.js Server Components not revalidating cached data correctly?

Next.js Server Components may not revalidate cached data correctly if caching strategies are misconfigured. Apply explicit revalidation using time-based revalidate values, cache tags, or path-based revalidation to control data freshness.

Can I build a production-grade full-stack React architecture using Next.js App Router?

Yes, you can build a production-grade full-stack React architecture using Next.js App Router. It provides Server Components, route handlers, and streaming patterns required for predictable performance and maintainable applications.