next-best-practices

Guide Next.js development with file conventions, RSC boundaries, and data fetching patterns.

Updated Feb 11, 2026
One-click install
npx skills add https://github.com/lexand-dev/subtrack-monorepo --skill next-best-practices-lexand-dev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-best-practices
Source: https://github.com/lexand-dev/subtrack-monorepo/tree/main/.agents/skills/next-best-practices
Command: npx skills add https://github.com/lexand-dev/subtrack-monorepo --skill next-best-practices-lexand-dev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides comprehensive guidance and best practices for developing with Next.js, ensuring efficient, maintainable, and performant applications.

Core Features & Use Cases

  • File Conventions: Understand project structure, route segments, and special files.
  • RSC Boundaries: Detect and prevent invalid React Server Component patterns.
  • Data Patterns: Choose the right data fetching strategy (Server Components, Server Actions, Route Handlers).
  • Error Handling: Implement robust error handling with error.tsx and global-error.tsx.
  • Optimization: Learn about image, font, and bundling optimizations.
  • Use Case: A developer is unsure about the correct way to fetch data in a new Next.js app and wants to ensure they are following recommended patterns for performance and maintainability.

Quick Start

Review the file conventions for Next.js App Router.

Frequently Asked Questions about next-best-practices

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

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

The best way to fetch data in Next.js depends on your component boundaries: use React Server Components for direct fetching, Server Actions for mutations, and Route Handlers for external API endpoints. This guide helps you choose the correct pattern for performance.

How do I handle errors in Next.js App Router?

Handle Next.js errors using `error.tsx` for route-level boundaries and `global-error.tsx` for root-level recovery. This Skill explains how to implement robust error handling to catch runtime issues and prevent full application crashes.

How do React Server Component boundaries work in Next.js?

React Server Component boundaries separate server-only logic from client interactivity in Next.js. This guide helps detect and prevent invalid RSC patterns, ensuring you correctly apply directives and maintain optimal component boundaries.

How do I optimize images and fonts in Next.js?

Optimize Next.js images and fonts by leveraging built-in bundling strategies and optimization techniques. This Skill provides expert guidance on configuring these assets to ensure efficient loading and robust application performance.

When should I use error.tsx versus global-error.tsx in Next.js?

Use `error.tsx` for segment-specific error boundaries and `global-error.tsx` to catch root-level exceptions in Next.js. This Skill details how to implement both to ensure robust error handling across your application's route segments.

Why does my Next.js data fetching pattern fail in client components?

Data fetching in Next.js client components fails when invalid React Server Component patterns are used. This guide helps detect these boundary violations and offers solutions for moving fetch logic to the correct server-side runtime.