htmx 4.0 is under construction — migration guide

htmx.config.sse

Server-Sent Events configuration

The htmx.config.sse option is a configuration object for Server-Sent Events (SSE) behavior.

Default:

{ reconnect: false, reconnectDelay: 500, reconnectMaxDelay: 60000, reconnectMaxAttempts: 10, reconnectJitter: 0.3, pauseInBackground: false }

Properties

  • reconnect - Auto-reconnect on disconnect
  • reconnectDelay - Initial delay in ms before reconnecting
  • reconnectMaxDelay - Maximum delay in ms (uses exponential backoff)
  • reconnectMaxAttempts - Maximum reconnection attempts
  • reconnectJitter - Jitter factor (0-1) to randomize reconnect timing
  • pauseInBackground - Pause SSE streams when tab is not visible

Example

htmx.config.sse.reconnect = true; htmx.config.sse.reconnectDelay = 1000;
<meta name="htmx-config" content='{"sse":{"reconnect":true,"reconnectDelay":1000}}'>