nextjs-best-practices

Provide Next.js App Router best practices for components, data fetching, routing, and performance.

Updated Jan 31, 2026
One-click install
npx skills add https://github.com/tuyenht/Antigravity-Core --skill nextjs-best-practices-tuyenht
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nextjs-best-practices
Source: https://github.com/tuyenht/Antigravity-Core/tree/main/.agent/skills/nextjs-best-practices
Command: npx skills add https://github.com/tuyenht/Antigravity-Core --skill nextjs-best-practices-tuyenht

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides clear, actionable guidance to implement Next.js App Router effectively, ensuring optimal performance, maintainability, and adherence to modern web development standards.

Core Features & Use Cases

  • Component Strategy: Differentiates between Server and Client Components and when to use each.
  • Data Fetching: Outlines effective strategies for fetching data, including caching and revalidation.
  • Routing: Explains file conventions and advanced routing patterns like route groups and parallel routes.
  • API Routes: Details best practices for creating robust API endpoints.
  • Performance: Covers image optimization, bundle analysis, and Next.js configuration for speed.
  • Caching: Explains different cache layers and revalidation techniques.
  • Server Actions: Guides on using Server Actions for mutations and revalidation.
  • Anti-Patterns: Highlights common mistakes to avoid.
  • Use Case: A developer starting a new Next.js project can use this Skill to set up their project structure and understand the core principles of App Router development from the outset, avoiding common pitfalls.

Quick Start

Review the principles for Next.js App Router development.

Frequently Asked Questions about nextjs-best-practices

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

FAQPage Schema
What are the best practices for Next.js App Router component strategy?

Next.js App Router component strategy best practices involve differentiating between Server and Client Components to optimize performance. You should default to Server Components and only use Client Components when you need interactivity, state, or browser APIs.

How do I fetch data and manage caching in Next.js App Router?

Data fetching in Next.js App Router should leverage the built-in fetch API extensions for caching and revalidation. Best practices include using different cache layers and revalidation techniques to ensure efficient data retrieval without compromising content freshness.

When should I use Server Actions for mutations in Next.js?

Server Actions in Next.js should be used for data mutations and form submissions directly within your components. They allow you to mutate data and trigger revalidation without creating separate API endpoints, streamlining the client-server interaction.

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

Common Next.js App Router anti-patterns include unnecessarily converting Server Components to Client Components, improper use of data fetching strategies, and ignoring caching layers. Avoiding these mistakes ensures your web application maintains optimal performance and maintainability.

How do I structure routes and API endpoints in a Next.js project?

Structuring routes in Next.js App Router involves using file conventions, route groups, and parallel routes for advanced patterns. API routes should follow robust endpoint creation practices to handle requests efficiently within your project structure.

Does this Next.js guide cover performance optimization and bundle analysis?

Yes, this Next.js guide covers performance optimization including image optimization, bundle analysis, and framework configuration. These practices ensure your web application achieves optimal speed and efficiency during development and production.