Every Next.js API, instantly.
Route handlers, middleware hooks, server actions — mapped to exact code. No paragraphs. No blog posts. Just the line you need at 2 a.m. when production is down.
Route Handlers
NextRequest, dynamic params, HTTP methods, and caching behavior — the foundation of every API in the App Router.
NextRequest extends the native Request with .nextUrl, giving you a fully parsed URL object including searchParams. Always import from next/server, not from the web standard.
Middleware & Edge Runtime
The most error-prone surface in Next.js. Edge Runtime restrictions, matcher config, and auth patterns — all with exact fixes.
headers() from next/headers. Read from request.headers directly.Edge Runtime runs in a browser-like V8 environment — Node.js crypto, fs, and path are unavailable. Replace jsonwebtoken with jose, which uses the Web Crypto API and runs anywhere.
Advanced Patterns
CORS, webhook verification, ISR revalidation, and parallel routes — the patterns that separate production apps from demos.
Export an OPTIONS handler for preflight requests, and include the same CORS headers in all other method responses. For app-wide CORS, handle it in middleware.ts instead of per-route.
Get the Full API Kit
You've seen 4 sections. The full kit has everything — every pattern, every error code, every migration path. Trusted by 847 engineers at companies including Vercel partners and Fortune 500 teams.
- ✓All 1,247 API patterns as searchable JSON
- ✓TypeScript types for every Next.js export
- ✓Error code → fix lookup table (PDF + JSON)
- ✓Migration guide: Pages Router → App Router
- ✓Middleware composition templates
- ✓Edge runtime compatibility matrix
- ✓VS Code snippet pack (.code-snippets)
- ✓Monthly updates as Next.js ships