next-best-practices

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

Updated Sep 10, 2026
One-click install
npx skills add https://github.com/sharad07072007/paras --skill next-best-practices-sharad07072007
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-best-practices
Source: https://github.com/sharad07072007/paras/tree/main/.agents/plugins/vercel/skills/nextjs/upstream
Command: npx skills add https://github.com/sharad07072007/paras --skill next-best-practices-sharad07072007

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing correct Next.js code requires tracking many evolving rules: async request APIs in v15+, Server/Client Component boundaries, middleware-to-proxy renames in v16, and proper image, font, and script optimization. This Skill consolidates those rules so code is written or reviewed correctly the first time. ## Core Features & Use Cases - RSC Boundary Validation: Detects invalid patterns like async client components and non-serializable props (Date, Map, class instances) passed across the server/client boundary. - Async API Migration Guidance: Covers Next.js 15+ async params, searchParams, cookies(), and headers(), including the official codemod. - Optimization Rules: Enforces next/image, next/font, and next/script usage with correct configuration for remote images, responsive sizes, and third-party scripts. - Use Case: When reviewing a pull request that adds a new dynamic route, apply this Skill to verify async params handling, metadata generation, error boundaries, and Suspense placement all follow current Next.js conventions. ## Quick Start Review my Next.js page component for best practice violations including async params handling, RSC boundaries, and image optimization.

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 and 16?

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. Run npx @next/codemod@latest next-async-request-api to migrate automatically.

Why can't I pass a Date object to a Client Component in Next.js?

Props crossing the Server/Client boundary must be JSON-serializable, and Date objects lose their methods during serialization. Convert dates with .toISOString() on the server, then reconstruct with new Date() inside the client component.

Should I use Server Actions or Route Handlers for mutations?

Use Server Actions for mutations triggered from your own UI, such as form submissions, since they offer type safety and progressive enhancement. Use Route Handlers for webhooks, external API consumers, and public REST endpoints.

Why does useSearchParams cause my whole page to become client-rendered?

useSearchParams triggers a client-side rendering 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 server-rendered.

What changed with middleware in Next.js 16?

Next.js 16 renames middleware.ts to proxy.ts, with the exported function renamed to proxy and config renamed to proxyConfig. The capabilities are identical, and the official upgrade codemod performs the rename automatically.

How do I fix hydration mismatch errors in Next.js?

Hydration errors come from browser-only APIs, timezone-dependent dates, random values, or invalid HTML nesting. Gate browser APIs behind a mounted check, render dates on the client only, use useId for IDs, and fix invalid nesting like div inside p.