PluginBench
Skill
Official
Fail
Audit score 45

next-best-practices

vercel-labs/openreview

Next.js best practices reference for file conventions, RSC boundaries, data patterns, and optimization.

What is next-best-practices?

A comprehensive guide to Next.js development patterns covering file structure, React Server Components, async APIs, error handling, and performance optimization. Use this when writing or reviewing Next.js code to ensure compliance with framework conventions and best practices.

  • Enforces file conventions and route segment patterns including dynamic, catch-all, and parallel routes
  • Detects invalid React Server Component patterns and non-serializable props
  • Guides async API usage for params, searchParams, cookies, and headers in Next.js 15+
  • Provides error handling strategies with error.tsx, not-found.tsx, and redirect functions
  • Optimizes images and fonts using next/image and next/font with responsive sizing and preloading
  • Covers data fetching patterns, route handlers, metadata generation, and bundling best practices

How to install next-best-practices

npx skills add https://github.com/vercel-labs/openreview --skill next-best-practices
Claude Code
Cursor
Windsurf
Cline

How to use next-best-practices

  1. 1.Reference the appropriate guide (file-conventions.md, rsc-boundaries.md, etc.) based on the code pattern you're reviewing
  2. 2.Check file structure against file-conventions.md for correct naming and organization
  3. 3.Validate React Server Component usage and async patterns against rsc-boundaries.md and async-patterns.md
  4. 4.Apply error handling patterns from error-handling.md for custom error pages and redirects
  5. 5.Implement image and font optimization using guidelines from image.md and font.md
  6. 6.Use the MCP endpoint or debug-build-paths flag for AI-assisted debugging when needed

Use cases

Good for
  • Reviewing Next.js code to catch RSC boundary violations and async pattern misuse
  • Setting up project structure with correct file conventions and route organization
  • Optimizing Core Web Vitals through image priority, font preloading, and script loading strategies
  • Implementing error boundaries and custom error pages for production applications
  • Migrating to Next.js 15+ async APIs and updating deprecated patterns
Who it's for
  • Next.js developers building full-stack applications
  • Code reviewers ensuring Next.js best practices compliance
  • Teams migrating to Next.js 15+ async patterns
  • Developers optimizing performance and Core Web Vitals
  • AI coding agents assisting with Next.js code generation and review

next-best-practices FAQ

When should I use Server Actions vs Route Handlers?

Use Server Actions for mutations and client-to-server communication from components; use Route Handlers for building APIs, webhooks, or when you need full HTTP method control.

What causes hydration errors and how do I fix them?

Hydration errors occur when server and client render different content, commonly from browser APIs, date/time differences, or invalid HTML. The error overlay provides specific fixes for each cause.

How do I optimize images in Next.js?

Always use next/image instead of img tags, configure remote image domains, set responsive sizes attributes, add blur placeholders, and mark LCP images with priority={true}.

What is the difference between 'use client' and 'use server'?

'use client' marks a component boundary for client-side rendering; 'use server' marks individual functions as Server Actions callable from clients. 'use cache' is a Next.js directive for caching.

How do I handle async params and searchParams in Next.js 15+?

In Next.js 15+, params and searchParams are async and must be awaited. Use the migration codemod to update existing code, and always await these values before accessing their properties.

Full instructions (SKILL.md)

Source of truth, from vercel-labs/openreview.


name: next-best-practices description: Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling user-invocable: false

Next.js Best Practices

Apply these rules when writing or reviewing Next.js code.

File Conventions

See file-conventions.md for:

  • Project structure and special files
  • Route segments (dynamic, catch-all, groups)
  • Parallel and intercepting routes
  • Middleware rename in v16 (middleware → proxy)

RSC Boundaries

Detect invalid React Server Component patterns.

See rsc-boundaries.md for:

  • Async client component detection (invalid)
  • Non-serializable props detection
  • Server Action exceptions

Async Patterns

Next.js 15+ async API changes.

See async-patterns.md for:

  • Async params and searchParams
  • Async cookies() and headers()
  • Migration codemod

Runtime Selection

See runtime-selection.md for:

  • Default to Node.js runtime
  • When Edge runtime is appropriate

Directives

See directives.md for:

  • 'use client', 'use server' (React)
  • 'use cache' (Next.js)

Functions

See functions.md for:

  • Navigation hooks: useRouter, usePathname, useSearchParams, useParams
  • Server functions: cookies, headers, draftMode, after
  • Generate functions: generateStaticParams, generateMetadata

Error Handling

See error-handling.md for:

  • error.tsx, global-error.tsx, not-found.tsx
  • redirect, permanentRedirect, notFound
  • forbidden, unauthorized (auth errors)
  • unstable_rethrow for catch blocks

Data Patterns

See data-patterns.md for:

  • Server Components vs Server Actions vs Route Handlers
  • Avoiding data waterfalls (Promise.all, Suspense, preload)
  • Client component data fetching

Route Handlers

See route-handlers.md for:

  • route.ts basics
  • GET handler conflicts with page.tsx
  • Environment behavior (no React DOM)
  • When to use vs Server Actions

Metadata & OG Images

See metadata.md for:

  • Static and dynamic metadata
  • generateMetadata function
  • OG image generation with next/og
  • File-based metadata conventions

Image Optimization

See image.md for:

  • Always use next/image over <img>
  • Remote images configuration
  • Responsive sizes attribute
  • Blur placeholders
  • Priority loading for LCP

Font Optimization

See font.md for:

  • next/font setup
  • Google Fonts, local fonts
  • Tailwind CSS integration
  • Preloading subsets

Bundling

See bundling.md for:

  • Server-incompatible packages
  • CSS imports (not link tags)
  • Polyfills (already included)
  • ESM/CommonJS issues
  • Bundle analysis

Scripts

See scripts.md for:

  • next/script vs native script tags
  • Inline scripts need id
  • Loading strategies
  • Google Analytics with @next/third-parties

Hydration Errors

See hydration-error.md for:

  • Common causes (browser APIs, dates, invalid HTML)
  • Debugging with error overlay
  • Fixes for each cause

Suspense Boundaries

See suspense-boundaries.md for:

  • CSR bailout with useSearchParams and usePathname
  • Which hooks require Suspense boundaries

Parallel & Intercepting Routes

See parallel-routes.md for:

  • Modal patterns with @slot and (.) interceptors
  • default.tsx for fallbacks
  • Closing modals correctly with router.back()

Self-Hosting

See self-hosting.md for:

  • output: 'standalone' for Docker
  • Cache handlers for multi-instance ISR
  • What works vs needs extra setup

Debug Tricks

See debug-tricks.md for:

  • MCP endpoint for AI-assisted debugging
  • Rebuild specific routes with --debug-build-paths