URL to connect to
OptionalheadersAdditional request headers
OptionalfetchFetch function (injectable for testing / custom auth)
Optionalinit: RequestInitOptionalinit: RequestInitOptionalsignalAbortSignal to stop the stream
OptionallastInitial Last-Event-ID to send on first connect
OptionalreconnectAuto-reconnect on disconnect (default: true)
OptionalreconnectInitial reconnect delay in ms (default: 3000)
OptionalmaxMax reconnect delay in ms (default: 30000)
OptionalreconnectJitter factor 0–1 (default: 0.3)
OptionalmaxMax reconnect attempts. 0 = infinite (default: 0)
OptionalonCalled before each reconnect attempt
OptionalonCalled on SSE parse errors
OptionalheartbeatHeartbeat timeout in ms — close if no event received (default: 0 = disabled).
When the timeout fires:
reconnect is enabled, the client attempts to reconnectonReconnect callback is invoked with the reconnect attempt countUse this to detect stale connections that aren't properly closed by the server.
OptionalmethodRequest method (default: GET)
OptionalbodyRequest body (for POST-based SSE)
OptionalvalidateValidate response before reading the stream.
Return true to accept, false for a generic error, or a string error message.
Configuration for creating an SSE client stream.