next-best-practices

Applies Next.js best practices for routing, data fetching, metadata, and optimization.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Next.js applications often suffer from subtle mistakes like invalid RSC boundaries, data waterfalls, hydration mismatches, and misconfigured images or fonts. This Skill provides a structured rulebook so AI agents and developers write and review Next.js code correctly the first time. ## Core Features & Use Cases - RSC Boundary Validation: Detects invalid patterns like async client components and non-serializable props passed across the server/client boundary. - Data Fetching Guidance: Helps choose between Server Components, Server Actions, and Route Handlers, and avoid waterfalls with Promise.all, Suspense, and preload patterns. - Optimization Rules: Covers next/image, next/font, next/script, metadata and OG image generation, bundling fixes, and self-hosting with standalone output and cache handlers. - Use Case: When building a Next.js 15+ page with dynamic params, use this Skill to correctly await params, generate metadata, and wrap useSearchParams in a Suspense boundary. ## Quick Start Review my Next.js page component and fix any violations of Next.js best practices.

Frequently Asked Questions about next-best-practices

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

FAQPage Schema
How do I handle async params in Next.js 15?

In Next.js 15+, params and searchParams are Promises that must be awaited. Type them as Promise<{ slug: string }> and await them in pages, layouts, route handlers, and generateMetadata. A codemod (npx @next/codemod@latest next-async-request-api) automates migration.

When should I use Server Actions vs Route Handlers?

Use Server Actions for mutations triggered from your UI like form submissions, since they offer type safety and progressive enhancement. Use Route Handlers for external APIs, webhooks, mobile clients, and GET endpoints needing HTTP caching.

Why does my Next.js page have a hydration error?

Hydration errors occur when server and client HTML differ, commonly from browser APIs like window, dates rendered in different timezones, random values, or invalid HTML nesting. Fix by rendering dynamic values client-side with useEffect or the useId hook.

Can I pass functions from Server to Client Components?

No, props crossing the server/client boundary must be JSON-serializable, so plain functions are invalid. The exception is Server Actions marked with 'use server', which can be passed to client components. Dates, Maps, and class instances must also be serialized first.

How do I self-host Next.js with Docker?

Set output: 'standalone' in next.config.js to produce a minimal server.js with production dependencies, then copy .next/static and public folders into your container. For multi-instance ISR, configure a custom cache handler backed by Redis or S3.

Why does useSearchParams cause client-side rendering of my whole page?

useSearchParams triggers a CSR bailout in static routes unless wrapped in a Suspense boundary. Wrap the component using it in <Suspense> with a fallback so the rest of the page stays statically rendered.