next-best-practices

Review Next.js App Router code for RSC boundaries and async API usage.

Updated Nov 1, 2024
One-click install
npx skills add https://github.com/artreimus/ylang-labs-blog --skill next-best-practices-artreimus
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-best-practices
Source: https://github.com/artreimus/ylang-labs-blog/tree/main/.agents/skills/next-best-practices
Command: npx skills add https://github.com/artreimus/ylang-labs-blog --skill next-best-practices-artreimus

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents common production-grade Next.js mistakes by turning hard-to-debug runtime issues into clear, actionable review rules for App Router, RSC boundaries, data patterns, and core performance/SEO conventions.

Core Features & Use Cases

  • RSC Boundary Guardrails: Detect invalid async patterns in Client Components and prevent non-serializable server-to-client props.
  • Correct Next.js 15+ Async APIs: Apply the required Promise-based usage for params, searchParams, cookies(), and headers(), including the generateMetadata flow.
  • Reliable Data & Routing Patterns: Choose the right mechanism between Server Components, Server Actions, and Route Handlers, avoiding route conflicts and data waterfalls.
  • Production Readiness Checks: Enforce conventions for error boundaries (error.tsx, global-error.tsx, not-found.tsx), hydration safety, route-handler environment constraints, and modal route behavior with parallel/intercepting routes.
  • Performance & SEO Best Practices: Standardize metadata + OG image generation, next/image usage, next/font optimization, runtime selection (Node vs Edge), bundling fixes for server-incompatible packages, and script loading via next/script.

Quick Start

Apply these rules while reviewing a Next.js App Router pull request that fails due to RSC boundary errors, incorrect async request usage, and hydration mismatches.

Frequently Asked Questions about next-best-practices

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

FAQPage Schema
How do I fix RSC boundary violations in Next.js App Router?

To fix RSC boundary violations in Next.js App Router, ensure server-to-client component props are fully serializable and avoid using async request APIs directly within Client Components. This Skill enforces those constraints during code review to prevent runtime boundary errors.

Why do my Next.js 15 async APIs like cookies() and params throw errors?

Next.js 15 async APIs like cookies() and params throw errors when not treated as Promises. This Skill applies the required Promise-based usage pattern for params, searchParams, cookies(), and headers(), including the generateMetadata flow, to resolve these issues.

What is the best way to handle error boundaries and not-found pages in Next.js?

The best way to handle error boundaries in Next.js is to implement error.tsx, global-error.tsx, and not-found.tsx file conventions. This Skill provides deterministic guidance on navigation and error-handling semantics to ensure reliable production behavior.

How do I prevent data waterfalls when choosing between Server Actions and Route Handlers?

To prevent data waterfalls when choosing between Server Actions and Route Handlers, apply deterministic routing patterns that avoid conflicts. This Skill guides the correct mechanism selection between Server Components, Server Actions, and Route Handlers.

Can I use this Skill to standardize Next.js metadata and OG image generation?

Yes, you can use this Skill to standardize Next.js metadata and OG image generation. It enforces performance and SEO configuration requirements, including next/image usage, next/font optimization, and proper script loading via next/script.

How do I fix hydration mismatches and server-incompatible package bundling issues in Next.js?

To fix hydration mismatches and server-incompatible package bundling issues in Next.js, this Skill enforces hydration safety rules and provides bundling fixes for server-incompatible packages, ensuring deterministic runtime selection between Node and Edge.