AHA demos
← All demos

Who's online

A live count of browsers looking at this page. Open it in another browser, or send the link to a friend, and watch the number go up.

1

Just you here right now.

Server time 10:44:27 UTC. Refreshes every 3 seconds.

What to look at

hx-trigger="every 3s" is polling. Every 3 seconds htmx asks the server for a fresh fragment and swaps it in. That is the whole client side.

Each poll also tells the server "I'm still here". The server updates a last_seen timestamp for your cookie and counts everyone seen in the last 10 seconds. Close the tab and you drop out of the count after a few seconds.

Two tabs in the same browser share a cookie, so they count as one. Use a private window or a different browser to see two.

Polling is not fancy, but it is robust. It survives sleeping laptops and flaky Wi‑Fi, and every request is a normal GET the server can cache or rate-limit.

Source

Loading source…

Every file of this demo, as it runs. Or browse it on GitHub ↗