10LOC

#streaming

Node.jsintermediate

Server-Sent Events (SSE) with plain res.write, no socket.io

import { createServer, type ServerResponse } from "node:http";

const clients = new Set<ServerResponse>();

const server = createServer((req, res) => {

A live event stream over plain HTTP using res.write and text/event-stream — no WebSocket library, no socket.io, and free auto-reconnect in the browser.

Bunintermediate

Streaming a file response with Bun.file(), no extra deps

import { serve, file } from "bun";

const server = serve({
  async fetch(req) {
    const pathname = new URL(req.url).pathname;

Bun.file() returns a lazy file handle that streams straight into a Response, so serving a large file never buffers it fully in memory.