Module
server.sse_lifecycle
SSE lifecycle bridge — connection status for[sse-connect]elements.
htmx's SSE extension creates anEventSourceinternally but doesn't
surface connection lifecycle to the DOM in a way that's easy to style
or hook into. This script bridges that gap.
On everyhtmx:sseOpen and htmx:sseErrorevent, it updates a
data-sse-state attribute on the [sse-connect]element:
"connected"— EventSource is open"disconnected"— EventSource errored or closed
This enables pure-CSS connection indicators::
[data-sse-state="disconnected"] .sse-indicator { display: block; }
[data-sse-state="connected"] .sse-indicator { display: none; }
It also dispatcheschirp:sse:connected and chirp:sse:disconnected
custom events on the element for JS hooks.
Injected into full-page HTML responses viaHTMLInjectmiddleware.
Controlled byAppConfig(sse_lifecycle=True) (default: True).