next-best-practices

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Next.js developers frequently encounter subtle bugs and anti-patterns: invalid async client components, non-serializable props crossing RSC boundaries, hydration mismatches, data waterfalls, and misconfigured images, fonts, or scripts. This Skill provides a structured rulebook for writing and reviewing Next.js code correctly. ## Core Features & Use Cases - RSC Boundary Validation: Detects invalid patterns like async client components and non-serializable props (Date, Map, class instances) passed from Server to Client Components. - Modern Async API Guidance: Covers Next.js 15+ async params, searchParams, cookies(), and headers(), plus the migration codemod. - Performance & Optimization Rules: Enforces next/image, next/font, next/script usage, Suspense boundaries, parallel data fetching, and bundling fixes for server-incompatible packages. - Use Case: When reviewing a pull request that adds a new dashboard page, apply this Skill to verify the page uses async params correctly, wraps useSearchParams in Suspense, fetches data in parallel, and optimizes images with proper sizes attributes. ## Quick Start Review my Next.js page component for best practice violations and suggest 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 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?

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

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 webhooks, public REST APIs, and cacheable GET endpoints consumed by third parties.

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 fallback={...}> so the rest of the page stays statically rendered.

How do I fix 'window is not defined' errors in Next.js?

This error occurs when a package using browser APIs runs in a Server Component. Fix it by using dynamic(() => import('pkg'), { ssr: false }), wrapping usage in a client component, or adding the package to serverExternalPackages in next.config.js.

Should I use Edge runtime or Node.js runtime in Next.js?

Default to the Node.js runtime, which supports full Node APIs, file system access, and most npm packages. Only use Edge runtime when you have specific geographic latency requirements and have verified all dependencies are Edge-compatible.