Skip to content

Better SSE

Dead simple real-time server-to-client communication without WebSockets.

Features

Easy real-time communication

Operates directly over HTTP.
No pinging, long-polling or WebSockets required.

Multi-client broadcasting

Send events to individual clients or to many at once using broadcast channels.

Web standards compliant

Full compliance to the WHATWG SSE specification.
Support for modern web frameworks that use the Fetch API.

Event batching

Batch and send multiple events in a single transmission to improve performance and lower bandwidth usage.

First-class TypeScript

Written in TypeScript and ships with types directly.
Define types for state and event data.

Highly configurable

Modify reconnection time, message serialization, data sanitization, response headers and more (with good defaults.)

Set up in 10 lines of code

import { createSession } from "better-sse"
app.get("/sse", async (req, res) => {
const session = await createSession(req, res)
session.push("Hello world!")
})

Get started