Streaming Responses

In this example, the Fetch API is called to fetch a remote jQuery.js resource, and the resource is sent to a client in streaming mode in response to a request from the client.

Sample Code

async function handleRequest(request) {
  const response = await fetch('');

  if (response.status !== 200) {
    return response;

  // Generate readable streams and writeable streams.
  const { readable, writable } = new TransformStream();
  // Respond to the client in streaming mode.

  return new Response(readable, response);

addEventListener('fetch', event => {

Sample Preview

In the address bar of the browser, enter a URL that matches a trigger rule of the Edge Function to preview the effect of the sample code.



  1. Runtime APIs: Fetch
  2. Runtime APIs: TransformStream
  3. Runtime APIs: Response