Next.js Rendering Runtime and Middleware
Pack:
nextjsSource:nextjs/nextjs-rendering-runtime-and-middleware/SKILL.mdUse this skill when the task is primarily about rendering model, runtime placement, or request interception before the route completes.
- Server Components vs Client Components as rendering boundaries
- static, dynamic, and streamed rendering choices
- route segment config and runtime selection
- Node.js vs Edge runtime tradeoffs
proxy.tsand matcher-based request interception- migration framing from legacy
middleware.tsnaming
Routing cues
Section titled “Routing cues”- rendering mode, streaming, component runtime split, route segment config, Node vs Edge, or middleware / proxy questions -> use this skill
- data reads and cache invalidation as the primary concern -> use
nextjs-data-fetching-and-cache - mutation flow or Route Handlers as the primary concern -> use
nextjs-server-actions-and-route-handlers - metadata and sitemap surfaces as the primary concern -> use
nextjs-metadata-seo-and-file-conventions
Default path
Section titled “Default path”- Read references/rendering-runtime-and-proxy.md first.
- Decide the rendering boundary before adding
'use client'or Edge runtime flags. - Keep
proxy.tsnarrow and matcher-driven. Route endpoint logic elsewhere. - Choose runtime based on platform constraints, package support, and latency goals, not fashion.
When to deviate
Section titled “When to deviate”- Add
'use client'only when state, effects, refs, or browser APIs force a client boundary. - Use Edge runtime only when latency, geography, or platform constraints justify the narrower compatibility surface.
- Reach for
proxy.tsonly when the request truly needs interception before the route completes. - Move to the data or server-boundary skills when rendering is no longer the main decision surface.
Quick example
Section titled “Quick example”export const runtime = 'edge'Guardrails
Section titled “Guardrails”- Server Components are the default. Client Components are an opt-in boundary.
- Do not use
proxy.tsas a general replacement for Route Handlers or app business logic. - The
middlewarefile convention is deprecated; useproxy.ts/proxy.jsterminology and file naming. - Edge runtime compatibility is narrower than Node.js. Verify package support before moving code there.
- Prefer explicit matcher rules and keep interception logic easy to reason about.
- adding
'use client'high in the tree without a concrete runtime need - moving code to Edge because it sounds faster without checking compatibility
- using
proxy.tsas a dumping ground for business logic - mixing rendering guidance with mutation or cache policy advice unless that surface is truly dominant
Verification checklist
Section titled “Verification checklist”- server vs client boundaries are explicit and justified
- runtime choice is tied to real constraints, not habit
proxy.tsremains narrow and matcher-based- deprecated
middlewarenaming is not suggested for new work - the response routes out if cache or mutation concerns now dominate
Canonical surfaces
Section titled “Canonical surfaces”'use client'runtimepreferredRegionmaxDurationproxy.tsNextRequestNextResponse
Maintenance
Section titled “Maintenance”- Snapshot date: 2026-04-03
- Package snapshot:
next@16.2.2 - Docs status snapshot: official docs now document
proxy.tsas the request-interception file convention and mark legacymiddlewarenaming as deprecated