← Playground index

Datastar over SSE

A page driven entirely by Datastar: on load it opens one long-lived stream (/ds/feed) that the server pushes state through, and every button below is a short SSE stream of its own that answers with patches and ends. Element patches (outer, inner, append), signal patches, signals sent both as query and as JSON body, a stream that keeps going for a while, and broadcasts to every tab. Open it twice and use one tab; state is shared by everyone, on purpose.

Server clock

A signal patch a second, broadcast on the feed.

Tabs subscribed

Broadcast when a feed opens or closes: close a tab and watch it drop.

Shared counter

POST, signals as JSON body. The server bumps the count and patches the signal to every tab.

Messages

The text travels as the message signal; the server appends a list item to every tab (patch-elements, mode append) and clears the input by patching the signal back to empty.

A job that streams its progress

One request whose stream stays open for a few seconds, patching the bar as it goes (mode inner). The button is disabled by Datastar's indicator signal while the stream is open.