next-best-practices
Installation
SKILL.md
Next.js v16 Best Practices
Apply these rules when writing or reviewing Next.js 16+ code.
Scope
Target: Next.js 16+, App Router, Node.js 20.9+, TypeScript 5+.
Next.js 16 Patterns
- proxy.ts: Replaces
middleware.ts. Runs on Node.js runtime. Useexport function proxy(request: NextRequest)andexport const config = { matcher }. Same redirect/rewrite/headers/cookies APIs. Migration:npx @next/codemod@canary middleware-to-proxy . - Turbopack: Default bundler; opt out with
next build --webpack,next dev --webpack - Cache Components: Opt-in via
cacheComponents: trueand"use cache"directive; PPR-ready - Async APIs:
params,searchParams,cookies(),headers()are async; useawait - Caching:
revalidateTag(tag, profile)requires second arg;updateTag()in Server Actions for read-your-writes;refresh()for uncached data