nextjs-best-practices

Guide Next.js App Router development with Server and Client Components.

41|12|Updated Jan 16, 2026
One-click install
npx skills add https://github.com/nguyenphp/antigravity-marketing --skill nextjs-best-practices-nguyenphp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-best-practices
Source: https://github.com/nguyenphp/antigravity-marketing/tree/main/templates/.agent/skills/nextjs-best-practices
Command: npx skills add https://github.com/nguyenphp/antigravity-marketing --skill nextjs-best-practices-nguyenphp

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides clear, actionable guidance on implementing Next.js App Router effectively, helping developers avoid common pitfalls and build performant, maintainable applications.

Core Features & Use Cases

  • Component Strategy: Understand when to use Server vs. Client Components.
  • Data Fetching: Learn optimal patterns for fetching data efficiently.
  • Routing: Grasp file conventions and advanced routing techniques.
  • Performance: Implement image optimization and bundle analysis.
  • Use Case: A developer starting a new Next.js project can use this Skill to quickly establish a robust architecture and adhere to best practices from the outset.

Quick Start

Review the decision tree for Server vs Client Components to determine the correct component type for your UI element.

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 App Router?

Use Server Components for data fetching and static UI, and Client Components for interactivity. The Next.js App Router defaults to Server Components, moving Client Components to the leaves of your component tree to optimize performance.

What are the best practices for data fetching in Next.js App Router?

Data fetching best practices in Next.js App Router involve fetching data directly in Server Components to reduce client-side JavaScript. For client-side data requirements, extend the fetch API with caching and revalidation strategies or use Server Actions.

How do I optimize performance and bundle size in a Next.js application?

Optimize Next.js performance by using the built-in Image component for automatic optimization and running bundle analysis to minimize JavaScript. Rely on Server Components to reduce client bundle size and improve load times.

Can I use Server Actions for form submissions and mutations in Next.js?

Yes, Server Actions in Next.js handle form submissions and data mutations directly on the server. This approach eliminates the need for separate API routes while maintaining progressive enhancement and type safety.

What are common anti-patterns when building React apps with Next.js App Router?

Common Next.js App Router anti-patterns include unnecessary usage of Client Components, creating manual API routes for simple mutations, and ignoring caching rules. Following established best practices avoids these pitfalls and ensures maintainability.

How does metadata handling work in the Next.js App Router?

Metadata handling in Next.js App Router uses a dynamic, API-driven approach where you export a metadata object or generateMetadata function from layout and page files. This automatically injects meta tags for SEO.