Route Handler Design

Use when designing or reviewing Next.js Route Handlers (the `route.ts`/`route.js` file convention in App Router): when a Route Handler is the right public HTTP endpoint surface vs Server Actions or Server Components, the HTTP-method-as-export contract (GET/POST/PUT/PATCH/DELETE/HEAD/OPTIONS), the Web-standard Request/Response interface (no Node `req`/`res`), the body-parsing primitives (`request.json`/`formData`/`text`/`blob`/`arrayBuffer`) and one-shot body consumption, the default caching behavior of GET responses (NOT cached by default since Next 15; opt IN via `dynamic = 'force-static'`) and the Cache Components `use cache` model, async `params`/`cookies`/`headers` and `RouteContext` typed params, dynamic segments and search params, the rule that every Route Handler is a PUBLIC surface that must authenticate/authorize/validate inside the handler, manual CORS, runtime/deployment selection (Node default and recommended after Vercel folded standalone Edge Functions onto Vercel Functions; the Edge runtime sti

jacob-balslev Updated

File contents

jacob-balslev/skills/tree/main/skills/backend-engineering/route-handler-design commit 55160a8e8f

Frequently asked questions

npx skillmds@latest add jacob-balslev/route-handler-design-2