mcpField
N
nextjs-best-practices

nextjs-best-practices

github.com/xirothedevDevelopment286 installsUpdated 24w ago
Repository

About nextjs-best-practices

A prioritized practice guide for developers building and maintaining Next.js applications. It directs users to load relevant rules and examples on demand, and includes guidance for framework version upgrades.

Key features

  1. 01Covers routing, rendering, and data fetching
  2. 02Loads rule files and examples on demand
  3. 03Prioritizes categories by impact
  4. 04Includes Next.js upgrade guidance
  5. 05Favors official and versioned sources

Use cases

  1. 01Design App Router pages and layouts
  2. 02Debug caching and data fetching
  3. 03Review API routes and Server Actions
  4. 04Migrate older patterns to Next.js 16

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/xirothedev/skills --skill nextjs-best-practices

After installing, type/nextjs-best-practicesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

AGENTS.md
agents/
openai.yaml
dataset/api/proxy-rename/
correct.tsx
incorrect.tsx
notes.md
dataset/api/route-handlers/
correct.tsx
incorrect.tsx
notes.md
dataset/api/server-actions/
correct.tsx
incorrect.tsx
notes.md
dataset/arch/app-router/
correct.tsx
incorrect.tsx
notes.md
dataset/arch/file-conventions/
correct.tsx
incorrect.tsx
notes.md
dataset/bundle/barrel-imports/
correct.tsx
incorrect.tsx
notes.md
dataset/bundle/dynamic/
correct.tsx
incorrect.tsx
notes.md
dataset/bundle/font-optimization/
correct.tsx
incorrect.tsx
notes.md
dataset/client/boundary/
correct.tsx
incorrect.tsx
notes.md
dataset/client/no-forwardref/
correct.tsx

Details

From the project README

Next.js Best Practices

Use this skill as the highest-priority guide for all Next.js-related tasks. When a task touches Next.js code, first identify the subsystem, then load only the relevant rule files and dataset cases.

When to Apply

Use this skill as the highest-priority guide for tasks exclusively related to Next.js applications. Reference these guidelines when:

  • Writing or reviewing Next.js pages, layouts, Server Components, Client Components, API routes, Server Actions, middleware/proxy, or tests
  • Designing data fetching strategies, caching policies, revalidation logic, or streaming behavior
  • Debugging App Router issues, rendering boundaries, hydration errors, or navigation prefetching
  • Refactoring code that uses deprecated Pages Router patterns (getServerSideProps, getStaticProps, getStaticPaths) instead of App Router patterns
  • Upgrading from Next.js 13, 14, or 15 to Next.js 16

Load On Demand

Start with this file. Load detailed files only when the task needs them:

references/_sections.md
references/arch-app-router.md
references/server-components.md
references/data-fetching-caching.md
references/api-route-handlers.md
dataset/data/fetching-caching/correct.tsx
sources/inventory.json

Each rule file includes:

  • Why the pattern matters
  • Incorrect and correct examples
  • Version applicability (13/14/15/16)
  • Dataset path with larger before/after TypeScript/TSX examples
  • Official or curated source references

Rule Categories by Priority

Resolve conflicts by lower priority number first. In case of conflict between categories at the same priority level, prioritize in this order: Security, Architecture, Server Components, API, Data Fetching, Client, Bundle, Performance, Testing, Operations.

PriorityCategoryImpactPrefix
1Architecture & RoutingCRITICALarch-
2Server Components & RenderingCRITICALserver-
3API Routes & Server ActionsCRITICALapi-
4Data Fetching & CachingHIGHdata-
5Client Components & InteractivityHIGHclient-
6Bundle OptimizationMEDIUM-HIGHbundle-
7Performance & OptimizationMEDIUM-HIGHperf-
8Security & AuthMEDIUMsecurity-
9Testing StrategyMEDIUMtest-
10Operations & ConfigurationMEDIUMops-

Version Upgrade Guidance

Patterns deprecated or changed in Next.js 16.x:

Old Pattern (13/14/15)New Pattern (16+)Reference
middleware.tsproxy.ts (network boundary rename)references/api-proxy-rename.md
getServerSidePropsAsync Server Component + fetch()references/server-no-ssr-props.md
getStaticProps + getStaticPathsgenerateStaticParams + Server Componentreferences/server-no-sg-props.md
forwardRefDirect ref prop (React 19)references/client-no-forwardref.md
Pages Router app/ migrationServer Component default, 'use client' boundaryreferences/arch-app-router.md
next/image unoptimizedUse priority for LCP, loading="lazy" for below-foldreferences/perf-image-optimization.md

External Skill Packs

For deep React composition pattern guidance, use the vercel-composition-patterns skill. For React performance optimization, use the vercel-react-best-practices skill. This Next.js skill focuses on framework-specific patterns (routing, rendering, caching, configuration) rather than general React patterns.

Source Policy

Prefer official Next.js docs and versioned framework samples for framework semantics. Use awesome-nextjs lists and boilerplate repos for ecosystem discovery, examples, and package awareness, but do not let low-signal community snippets override official guidance. Refresh sources/inventory.json before publishing or using the skill for a new major Next.js version.

Comments

Markdown supported