Announcing Streaming Support for endpts Serverless Functions

endpts now supports response streaming for Serverless Functions out of the box.

Response streaming allows you to send data to the client as soon as it becomes available, instead of waiting for the entire response to be ready. This enables you to build functions that return larger payloads while also improving the time to first byte (TTFB) of your endpoints.

Since endpts Serverless Functions use the Standard Web APIs for the Request and Response objects, you can simply return a ReadableStream as the Response body to stream data back to the client:

import type { Route } from '@endpts/types'

export default {
  method: 'GET',
  path: '/stream',
  async handler() {
    let eventCount = 0

    const stream = new ReadableStream({
      start(controller) {
        controller.enqueue('stream started\n')
      async pull(controller) {
        controller.enqueue(`event: #${eventCount}\n`)

        return new Promise((r) => setTimeout(r, 500))

    return new Response(stream)
} satisfies Route
endpts response streaming demo

The endpts devtools have also been updated to enable you to develop and test your streaming endpoints locally.