next-best-practices

Provides Next.js best practices for file conventions, Server Components, data fetching, and optimization.

Updated Mar 12, 2026
One-click install
npx skills add https://github.com/MuhamadAnang/wareflow-project --skill next-best-practices-muhamadanang
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-best-practices
Source: https://github.com/MuhamadAnang/wareflow-project/tree/main/.agents/skills/next-best-practices
Command: npx skills add https://github.com/MuhamadAnang/wareflow-project --skill next-best-practices-muhamadanang

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers adhere to best practices in Next.js, preventing common pitfalls and ensuring efficient, maintainable code.

Core Features & Use Cases

  • File Conventions: Understand and apply Next.js's file-based routing and special file conventions.
  • RSC Boundaries: Detect and avoid invalid React Server Component patterns.
  • Data Patterns: Choose the right pattern (Server Components, Server Actions, Route Handlers) for data fetching and mutations.
  • Error Handling: Implement robust error handling with error.tsx and global-error.tsx.
  • Optimization: Apply best practices for image, font, and script optimization.
  • Use Case: A developer is unsure about the correct way to fetch data in a new Next.js 15+ application. This Skill provides clear guidelines on using Server Components, Server Actions, and Route Handlers, along with examples for avoiding data waterfalls.

Quick Start

Review the best practices for handling data fetching in Next.js Server Components.

Frequently Asked Questions about next-best-practices

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

FAQPage Schema
What is the best way to fetch data in Next.js App Router?

The best way to fetch data in Next.js App Router is by using React Server Components. This Skill guides you in choosing between Server Components, Server Actions, and Route Handlers to prevent data waterfalls and ensure efficient fetching.

How do I avoid invalid React Server Component boundaries in Next.js?

To avoid invalid React Server Component boundaries in Next.js, you must correctly separate server-only logic from client interactivity. This Skill helps detect and prevent invalid RSC patterns to ensure your component boundaries are properly maintained.

When do I need Route Handlers vs Server Actions for data mutations?

Route Handlers and Server Actions serve different data mutation needs in Next.js. This Skill provides guidelines on choosing the correct pattern for your data fetching and mutations based on your specific application requirements.

How do I implement error handling with error.tsx and global-error.tsx?

To implement error handling in Next.js, you use error.tsx for route-level boundaries and global-error.tsx for root-level recovery. This Skill outlines robust strategies for catching and resolving runtime errors effectively.

What are the optimization best practices for images and fonts in Next.js?

Optimization best practices for images and fonts in Next.js involve leveraging built-in components to reduce load times. This Skill details how to apply these optimization techniques correctly for images, fonts, and scripts.

Does this Next.js best practices guidance cover file conventions?

Yes, this Next.js best practices guidance covers file conventions. It explains how to understand and apply Next.js's file-based routing and special file conventions to ensure maintainable code.