nextjs-best-practices

Guides Next.js App Router development with Server Components, routing, and caching patterns.

1|Updated Aug 4, 2026
One-click install
npx skills add https://github.com/Hamzaoui-Louai/LEAN-gym-dashboard-frontend --skill nextjs-best-practices-hamzaoui-louai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-best-practices
Source: https://github.com/Hamzaoui-Louai/LEAN-gym-dashboard-frontend/tree/main/.opencode/skills/nextjs-best-practices
Command: npx skills add https://github.com/Hamzaoui-Louai/LEAN-gym-dashboard-frontend --skill nextjs-best-practices-hamzaoui-louai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers building Next.js applications often misuse Client Components, mishandle data fetching, or misconfigure caching, leading to bloated bundles and poor performance. This Skill provides structured principles for making correct architectural decisions in the App Router. ## Core Features & Use Cases - Server vs Client Component Guidance: Decision trees and tables for choosing between Server Components and 'use client' boundaries. - Data Fetching & Caching Patterns: Covers static rendering, ISR revalidation, no-store dynamic fetching, and on-demand revalidation with tags. - Routing & Project Structure: Documents file conventions (page.tsx, layout.tsx, loading.tsx, error.tsx), route groups, parallel routes, and intercepting routes. - Use Case: When building a dashboard with mixed static and interactive content, use this Skill to split Server and Client Components correctly, configure route-level caching, and add proper loading and error states. ## Quick Start Review my Next.js App Router page and tell me whether it should be a Server or Client Component with the right data fetching strategy.

Frequently Asked Questions about nextjs-best-practices

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

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

Use Server Components by default for data fetching, layouts, and static content. Add 'use client' only when you need useState, useEffect, or event handlers. For mixed needs, split into a Server parent with a Client child.

How do I configure caching and revalidation in Next.js App Router?

Next.js caches fetches statically by default. Use the revalidate option for time-based ISR, revalidatePath or revalidateTag for on-demand invalidation, and the no-store option for fully dynamic per-request data.

What are route groups and parallel routes in Next.js?

Route groups use (name) folders to organize routes without affecting the URL. Parallel routes use @slot folders to render multiple pages in the same layout, while intercepting routes with (.) enable modal overlays.

What are common Next.js App Router anti-patterns to avoid?

Avoid adding 'use client' everywhere, fetching data in client components, skipping loading.tsx and error.tsx states, and shipping large client bundles. Prefer Server Components by default and use dynamic imports for heavy components.

When should I use server actions instead of API route handlers?

Use server actions marked with 'use server' for form submissions, data mutations, and revalidation triggers. Use route handlers for external API endpoints. Always validate inputs with Zod and return typed responses.