Next.js Best Practices

Next.js Best Practices

✓ Verified

Comprehensive guidance for writing and reviewing Next.js code — RSC boundaries, async patterns, routing, error handling, and data fetching.

Claude / Claude Codetested
GitHub Copilottested
VS Codetested
Cursortested
OpenAI Codextested

What it does

Next.js App Router has enough sharp edges that Claude consistently generates code with subtle issues: `use client` directives placed too high in the component tree, async operations handled incorrectly in server components, data fetching that re-runs on every render because it's in the wrong place, and error boundaries missing from layouts that need them. This skill loads Vercel's Next.js-specific guidance: correct file conventions, server action patterns, middleware usage, route handler structure, and the specific places where App Router diverges from what Claude expects.

Use case

Any Next.js App Router project. Pair with vercel-react-best-practices for full coverage — this skill handles Next.js-specific patterns (routing, server actions, layouts), that one handles React patterns (components, hooks, rendering). Made by Vercel Labs.

The Prompt

Copy and use immediately
"Build a server action for this form that validates input and writes to the database."
"Why is this data fetching running twice? Fix the pattern."
"Add error handling to this route — the right place for the error boundary."
"Is my use of cookies in this server component correct?"
"Build a layout that wraps the dashboard routes with auth checking."

How to use

  1. 1

    Install in your Next.js project. Claude applies App Router patterns correctly to all generated code.

  2. 2

    For architecture questions: ask Claude about the correct pattern for your specific case — it explains the trade-off, not just the answer.

  3. 3

    Use for code review: ask Claude to audit a file for Next.js anti-patterns.

Input / Output

Input

Next.js component code, a feature description, or an architectural question about your application.

Output

Next.js code with correct App Router patterns: properly placed server/client boundaries, correct server action structure, appropriate Suspense usage, and accurate error boundary placement.

Install via CLI

npx skillsadd vercel-labs/next-skills/next-best-practices
Added 4 Apr 2026Submitted by vercel-labs👁 87📋 0

Details

Platforms
Claude / Claude CodeGitHub CopilotVS CodeCursorOpenAI Codex
Category
Development
License
MIT
Author
Vercel

Stats

📋 Copies0
👁 Views87
👍 Upvotes0

Install with skills.sh

npx skillsadd vercel-labs/skills/next-best-practices

Requires skills.sh CLI

Community Notes

Sign in with GitHub to leave a note.

No notes yet. Be the first to contribute.