August 2024
Intermediate to advanced
186 pages
4h 3m
English
Before moving on, try the following things to make sure you understand how to use htmx with WebSockets and server-sent events.
Create a web app that uses htmx and a WebSocket to report the current score of a basketball game. In the server code, start with both teams at zero points. Every few seconds, randomly choose one of the teams and randomly choose a number of points to add to their score, 2 or 3. Send a message to the client that contains the new score as a string containing the scores of the two teams separated by a dash.
Make a copy of the web app previously created and modify it to use server-sent events instead of a WebSocket.
Read now
Unlock full access