Dual Runtime Portability
Whether running on Node.js via app.listen() or in Edge environments (Cloudflare Workers, Bun, Deno) via app.createFetch(), the exact same ctx methods and properties work seamlessly without requiring code modifications:
| Property / Method | Node.js Runtime | Edge Runtime | Description |
|---|---|---|---|
Universal | string | string | HTTP method (e.g. "GET") |
Universal | string | string | Full request URL path and query string |
Universal | string | string | URL path without query string |
Universal | Record<string, string | string[]> | Record<string, string | string[]> | Parsed query parameters |
Universal | Record<string, string> | Record<string, string> | URL path parameters (e.g. :id) |
Universal | Record<string, unknown> | Record<string, unknown> | Per-request state object for middleware |
Universal | Record<string, string | string[]> | Record<string, string> | Incoming request headers |
Universal | Record<string, string> | Record<string, string> | Parsed cookies object |
Universal | string | string | Client IP address |
Universal | string | string | Request hostname |
Universal | string | string | Request host (includes port) |
Universal | "node" | "edge" | Current runtime environment indicator |
Platform Specific | http.IncomingMessage | Request (Web API) | The underlying request object. |
Platform Specific | http.ServerResponse | null | The underlying response object. |
Platform Specific | null | unknown | Cloudflare Workers / Edge environment bindings. |
Platform Specific | null | unknown | Edge ExecutionContext (e.g. ctx.waitUntil). |
Universal | Writes to ServerResponse | Resolves Response object | Sends plaintext, HTML, or Buffer payloads. |
Universal | Streams via JitCache | Resolves Response.json() | High-performance JSON serialization. |
Universal | Writes to ServerResponse | Resolves text Response | Sends plaintext payload. |
Universal | Writes to ServerResponse | Resolves ArrayBuffer Response | Sends binary payload. |
Universal | Sets res.statusCode | Sets internal edgeStatus | Sets the HTTP response status code. |
Universal | res.setHeader() | Headers.set() | Sets an outgoing response header. |
Universal | res.getHeader() | Headers.get() | Gets an outgoing response header. |
Universal | res.removeHeader() | Headers.delete() | Removes an outgoing response header. |
Universal | Appends Set-Cookie header | Appends Set-Cookie header | Sets an outgoing cookie. |
Universal | Reads & parses stream | Calls req.json() / req.text() | Parses JSON, Form-Data, or Text body. |
Universal | Custom Node.js parser | req.formData() generator | Async generator for multipart/form-data uploads. |
Universal | req as ReadableStream | req.body | Raw byte stream of the request body. |
Node.js Only | Streams file from disk | Throws Error | Streams a static file to the client. |
Node.js Only | Streams file as download | Throws Error | Forces a file download. |
Universal
HTTP method (e.g. "GET")
Universal
Full request URL path and query string
Universal
URL path without query string
Universal
Parsed query parameters
Universal
URL path parameters (e.g. :id)
Universal
Per-request state object for middleware
Universal
Incoming request headers
Universal
Parsed cookies object
Universal
Client IP address
Universal
Request hostname
Universal
Request host (includes port)
Universal
Current runtime environment indicator
Platform Specific
The underlying request object.
Platform Specific
The underlying response object.
Platform Specific
Cloudflare Workers / Edge environment bindings.
Platform Specific
Edge ExecutionContext (e.g. ctx.waitUntil).
Universal
Sends plaintext, HTML, or Buffer payloads.
Universal
High-performance JSON serialization.
Universal
Sends plaintext payload.
Universal
Sends binary payload.
Universal
Sets the HTTP response status code.
Universal
Sets an outgoing response header.
Universal
Gets an outgoing response header.
Universal
Removes an outgoing response header.
Universal
Sets an outgoing cookie.
Universal
Parses JSON, Form-Data, or Text body.
Universal
Async generator for multipart/form-data uploads.
Universal
Raw byte stream of the request body.
Node.js Only
Streams a static file to the client.
Node.js Only
Forces a file download.