Performance: Request parsing in route handlers
MEDIUM IMPACT
This affects server response time and how quickly the page can start rendering by controlling how fast the request data is processed.
export async function POST(req) { const body = await req.json(); // offload heavy processing to background task or optimize logic return new Response(JSON.stringify({ message: 'Done' }), { status: 200 }); }
export async function POST(req) { const body = await req.json(); // heavy synchronous processing here return new Response(JSON.stringify({ message: 'Done' }), { status: 200 }); }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Heavy synchronous parsing in route handler | 0 (server-side) | 0 | 0 | [X] Bad |
| Efficient async parsing with minimal processing | 0 (server-side) | 0 | 0 | [OK] Good |