Skip to content

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:

Dual Runtime Portability30 properties

Cross-runtime behavior of RequestContext methods and properties

Property / MethodNode.js RuntimeEdge RuntimeDescription
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
Typestring
Defaultstring
HTTP method (e.g. "GET")
Universal
Typestring
Defaultstring
Full request URL path and query string
Universal
Typestring
Defaultstring
URL path without query string
Universal
TypeRecord<string, string | string[]>
DefaultRecord<string, string | string[]>
Parsed query parameters
Universal
TypeRecord<string, string>
DefaultRecord<string, string>
URL path parameters (e.g. :id)
Universal
TypeRecord<string, unknown>
DefaultRecord<string, unknown>
Per-request state object for middleware
Universal
TypeRecord<string, string | string[]>
DefaultRecord<string, string>
Incoming request headers
Universal
TypeRecord<string, string>
DefaultRecord<string, string>
Parsed cookies object
Universal
Typestring
Defaultstring
Client IP address
Universal
Typestring
Defaultstring
Request hostname
Universal
Typestring
Defaultstring
Request host (includes port)
Universal
Type"node"
Default"edge"
Current runtime environment indicator
Platform Specific
Typehttp.IncomingMessage
DefaultRequest (Web API)
The underlying request object.
Platform Specific
Typehttp.ServerResponse
Defaultnull
The underlying response object.
Platform Specific
Typenull
Defaultunknown
Cloudflare Workers / Edge environment bindings.
Platform Specific
Typenull
Defaultunknown
Edge ExecutionContext (e.g. ctx.waitUntil).
Universal
TypeWrites to ServerResponse
DefaultResolves Response object
Sends plaintext, HTML, or Buffer payloads.
Universal
TypeStreams via JitCache
DefaultResolves Response.json()
High-performance JSON serialization.
Universal
TypeWrites to ServerResponse
DefaultResolves text Response
Sends plaintext payload.
Universal
TypeWrites to ServerResponse
DefaultResolves ArrayBuffer Response
Sends binary payload.
Universal
TypeSets res.statusCode
DefaultSets internal edgeStatus
Sets the HTTP response status code.
Universal
Typeres.setHeader()
DefaultHeaders.set()
Sets an outgoing response header.
Universal
Typeres.getHeader()
DefaultHeaders.get()
Gets an outgoing response header.
Universal
Typeres.removeHeader()
DefaultHeaders.delete()
Removes an outgoing response header.
Universal
TypeAppends Set-Cookie header
DefaultAppends Set-Cookie header
Sets an outgoing cookie.
Universal
TypeReads & parses stream
DefaultCalls req.json() / req.text()
Parses JSON, Form-Data, or Text body.
Universal
TypeCustom Node.js parser
Defaultreq.formData() generator
Async generator for multipart/form-data uploads.
Universal
Typereq as ReadableStream
Defaultreq.body
Raw byte stream of the request body.
Node.js Only
TypeStreams file from disk
DefaultThrows Error
Streams a static file to the client.
Node.js Only
TypeStreams file as download
DefaultThrows Error
Forces a file download.

Released under the MIT License.