nextjs-best-practices

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

Updated Jul 3, 2026
One-click install
npx skills add https://github.com/alex-jordan547/agent-setup --skill nextjs-best-practices-alex-jordan547
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-best-practices
Source: https://github.com/alex-jordan547/agent-setup/tree/main/archive/nextjs-best-practices
Command: npx skills add https://github.com/alex-jordan547/agent-setup --skill nextjs-best-practices-alex-jordan547

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers building with Next.js App Router often misuse Client Components, mishandle data fetching, or skip loading and error states, leading to bloated bundles and poor performance. This Skill provides structured principles for making correct architectural decisions. ## 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 revalidatePath/revalidateTag. - 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 page, use this Skill to structure a Server Component parent that fetches data, delegate interactivity to a small Client child, and add proper loading.tsx and error.tsx boundaries. ## Quick Start Review my Next.js App Router page component and tell me whether it should be a Server or Client Component with proper 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 decide between Server and Client Components in Next.js?

Use a Client Component with 'use client' when you need useState, useEffect, or event handlers; otherwise default to a Server Component. For components needing both, split into a Server parent that fetches data and a Client child that handles interactivity.

What data fetching strategy should I use in Next.js App Router?

Next.js defaults to static fetching cached at build time. Use the revalidate option for time-based ISR, 'no-store' for dynamic per-request data, and revalidatePath or revalidateTag for on-demand cache invalidation.

What do loading.tsx and error.tsx files do in Next.js?

loading.tsx renders an automatic loading UI while the route segment's data loads, and error.tsx acts as an error boundary catching runtime errors in that segment. Both are file conventions in the App Router.

When should I use Server Actions in Next.js?

Use Server Actions for form submissions, data mutations, and revalidation triggers. Mark functions with 'use server', validate all inputs with a library like Zod, return typed responses, and handle errors gracefully.

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

Avoid adding 'use client' everywhere, fetching data in client components, skipping loading states, ignoring error boundaries, and shipping large client bundles. Start with Server Components and add client interactivity only where needed.