Dynamic route handlers in Next.js
From the Next.js cheat sheet · API Routes · verified Jul 2026
Dynamic route handlers
typescript
// app/api/posts/[id]/route.ts💡 Access route params in API routes
⚡ Search params available via URL
📌 Combine with database queries
🟢 Type-safe with TypeScript