next-best-practices

Detect Next.js App Router anti-patterns and enforce best practices.

Updated Feb 27, 2024
One-click install
npx skills add https://github.com/MaxStrootmann/lumen-yoga --skill next-best-practices-maxstrootmann
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-best-practices
Source: https://github.com/MaxStrootmann/lumen-yoga/tree/main/.agents/skills/next-best-practices
Command: npx skills add https://github.com/MaxStrootmann/lumen-yoga --skill next-best-practices-maxstrootmann

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provide a concise, opinionated reference that prevents common Next.js mistakes and architectural anti-patterns, helping teams maintain correct RSC boundaries, consistent file conventions, and reliable data and metadata patterns across an App Router codebase.

Core Features & Use Cases

  • File Conventions & Routing: Guidance on project structure, dynamic and catch-all segments, parallel and intercepting routes, and middleware → proxy migration.
  • RSC Boundaries & Async Patterns: Rules to detect async client components, non-serializable props, server action usage, and new async request APIs.
  • Data, Metadata & Runtime Practices: Patterns for Server Components, Server Actions, Route Handlers, generateMetadata/OG images, image/font optimization, bundling pitfalls, and self-hosting considerations.
  • Error Handling & Debugging: Prescriptions for error.tsx/global-error, navigation gotchas, hydration fixes, MCP debugging, and build/debug tricks.

Quick Start

Review my Next.js app and list file-convention violations, invalid RSC boundaries, async API misuses, metadata and OG image issues, image/font mistakes, bundling problems, and recommended fixes.

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 invalid RSC boundaries and async client components in Next.js?

To fix invalid RSC boundaries in Next.js, detect async client components and non-serializable props passed to them. Enforce correct Server Component boundaries by moving async logic to server-only code and ensuring client components remain synchronous.

What are the best practices for Next.js App Router file conventions and routing?

Next.js App Router file conventions require correct project structure, dynamic segments, and proper route handler placement. Avoid route.ts conflicts by following parallel and intercepting route patterns, and apply middleware to proxy migration guidance for reliable routing.

Why does my Next.js app throw hydration errors and how do I debug them?

Next.js hydration errors usually stem from client-server markup mismatches or invalid async API misuse. Debug them by applying prescriptive remediation patterns, checking error.tsx and global-error boundaries, and resolving navigation gotchas that cause rendering inconsistencies.

How do I optimize images, fonts, and metadata for self-hosted Next.js apps?

Optimize Next.js images and fonts by avoiding bundling anti-patterns and applying correct optimization configurations. For self-hosting, ensure proper metadata setup, OG image generation via generateMetadata, and runtime practices that prevent resource loading pitfalls.

Can I use server actions and new async request APIs with Next.js Route Handlers?

Yes, you can use Next.js Server Actions and new async request APIs with Route Handlers by enforcing correct async patterns. Ensure server actions are properly scoped, avoid non-serializable props, and validate data fetching practices to maintain reliable runtime behavior.