req and res
The request and response objects that Node.js-style handlers receive, conventionally named req and res.
In more detail
req describes the incoming request and res is written to build the response, with methods such as res.status() and res.json(). They are Node.js objects, not the standard Web Request and Response.
Example
Next.js Pages Router API routes use them; App Router Route Handlers use Web Request and Response instead.Related terms
- API routes — The Pages Router way of writing back-end endpoints: files in pages/api that export a handler taking req and res.
- Request and Response — The standard Web API classes that represent an HTTP request and an HTTP response, shared by browsers, Node.js and edge platforms.
Taught in
- Server Actions: use server Directives & Mutations — Next.js 15 & Modern App Router Architecture
- Route Handlers: RESTful Endpoints with NextRequest — Next.js 15 & Modern App Router Architecture
- Edge Middleware: Auth Verification & Route Matchers — Next.js 15 & Modern App Router Architecture