nextjs-best-practices

Applies Next.js App Router best practices for components, routing, caching, and performance.

Updated Jun 12, 2026
One-click install
npx skills add https://github.com/bilacchi/agents-skills --skill nextjs-best-practices-bilacchi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nextjs-best-practices
Source: https://github.com/bilacchi/agents-skills/tree/main/skills/nextjs-best-practices
Command: npx skills add https://github.com/bilacchi/agents-skills --skill nextjs-best-practices-bilacchi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Next.js App Router introduces many architectural decisions—Server vs Client Components, caching layers, route conventions, and Server Actions—that developers often get wrong, leading to bloated client bundles, poor performance, and broken data flows. This Skill provides structured guidance to make the right choice every time. ## Core Features & Use Cases - Component Architecture Guidance: Decision trees for choosing Server vs Client Components and splitting mixed-interactivity UI correctly. - 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, layout, loading, error, not-found), route groups, parallel routes, and intercepting routes. - Use Case: When building a dashboard page that fetches database data and includes an interactive form, use this Skill to structure a Server Component parent that fetches data, a Client Component child for the form, and a Server Action for the mutation with proper revalidation. ## Quick Start Review my Next.js App Router page and tell me whether each component should be a Server or Client Component with correct data fetching and caching.

Frequently Asked Questions about nextjs-best-practices

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

FAQPage Schema
How do I choose between Server and Client Components in Next.js?▼

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

How does caching and revalidation work in Next.js App Router?▼

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

When should I use Server Actions instead of API routes?▼

Use Server Actions for form submissions, data mutations, and revalidation triggers directly from components. Use Route Handlers when you need a public REST API endpoint consumed by external clients. Always validate inputs with Zod in both cases.

What are the file conventions for Next.js App Router routes?▼

App Router uses page.tsx for route UI, layout.tsx for shared layouts, loading.tsx for loading states, error.tsx for error boundaries, and not-found.tsx for 404 pages. Route groups with parentheses organize files without affecting URLs.

Why is my Next.js client bundle too large?▼

Large bundles usually come from applying 'use client' too broadly or importing heavy libraries in Client Components. Keep components as Server Components by default and use dynamic imports for heavy client-side code, then verify with a bundle analyzer.