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.
In more detail
A Request holds the method, URL, headers and body; a Response holds the status, headers and body, which can be a stream. Because every platform shares them, code written against them is portable.
Example
Next.js Route Handlers and middleware receive a Request and return a Response, extended as NextRequest and NextResponse.Related terms
- NextRequest — Next.js' extension of the Web Request object, adding a cookies helper and nextUrl, a parsed URL with Next.js routing details.
- NextResponse — Next.js' extension of the Web Response object, with helpers for JSON responses, cookies, redirects and rewrites.
- Fetch API — The standard JavaScript function fetch() for making HTTP requests, built into browsers and current server runtimes, which returns a promise for the response.
- Web APIs — The standard interfaces defined for the web, such as fetch, Request, Response, URL, streams and Web Crypto.
Taught in
- Route Handlers: RESTful Endpoints with NextRequest — Next.js 15 & Modern App Router Architecture
- Streaming Endpoints: Server-Sent Events & NDJSON Feeds — Next.js 15 & Modern App Router Architecture