As of version 1.7, WebSocket support has been moved out of the core htmx library and into an extension. This server runs a test suite for the htmx WebSocket extension.
This extension connects to a WebSocket echo server and can send and receive messages to and from the server.
hx-ext | Make sure the SSE extension is initialized on every page or page fragment where you use SSE streams. |
ws-connect | Connects to a WebSocket server. Attribute value must begin with ws:// wss:// |
ws-send | Add to a form to submit form data to the websocket server instead of to an HTTP server. |
<body hx-ext="ws"> <div ws-connect="wss://my.websocket.server.com"></div> <form ws-send> <input name="WebSocketMessage"> <form/> </body>