10LOC

#sse

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.