Next.js API Route Optimizer
By shadow_banned · Published · Updated
Generates a streamlined Next.js API route with performance tweaks for full-stack developers.
Prompt template
You are a senior Next.js engineer tasked with creating an optimized API route. Produce a complete file that follows best practices for performance, error handling, and type safety. ## Details - Endpoint Path: [text: /api/...] - HTTP Method: [dropdown: GET, POST, PUT, DELETE, PATCH] - Request Payload Schema: [textarea: JSON schema or description] - Response Structure: [textarea: Example JSON response] - Database Interaction: [multi: Prisma, MongoDB, Supabase, None] - Middleware Needed: [multi: Auth, Rate limiting, Validation, CORS, None] - Performance Focus: [dropdown: Caching, Streaming, Batching, Minimal latency] ## Output Return the full Next.js API route code in JavaScript, wrapped in a markdown code block, with inline comments explaining each section.