Return web-standard responses

Besides JSX, strings, buffers and JSON, a route can return a standard Response object. Status, headers and body are taken from it. This makes it easy to reuse code written for other web-standard runtimes or to proxy a fetch call straight through.

CSV download

new Response(csv, { headers }) with a content-disposition header.

JSON

Response.json(data) sets body and content type in one go.

Redirect

new Response(null, { status: 303, headers }) sends the browser back here.

Custom status

new Response(body, { status: 418 }) for any status code.

Proxy

fetch(url) passes a remote response through, cached for five minutes.