← BACK TO PORTFOLIO

/WRITING · BUILDING WEB APPS

A real-time incident dashboard with WebSockets and TanStack Query

During the Binance hack, stolen funds kept moving for more than three hours. A dashboard that checks for updates every few minutes sees that late and blurred. Here is how I build live dashboards that keep up when it matters.

November 18, 20264 MIN READ
Cover illustration: a live outflow chart for a hot wallet with a velocity threshold line; a spike crosses the threshold and triggers a red alert badge.

One detail from the October 2026 Binance hack has stayed with me. After the attackers took over one of the exchange's wallets, it kept forwarding new deposits to them. TRM Labs lists those sweeps at 20:41, 20:59, 21:04, 21:44, 22:39 and 23:56 UTC. That is more than three hours of an attack that announced itself every time it ran.

Most monitoring dashboards would have shown it eventually. The question is how quickly and how clearly. This post is about building dashboards that keep up, for any business where minutes matter: payments, orders, security alerts or deliveries.

The problem: checking every few minutes is too slow in a crisis

The usual way to build a dashboard is to have it ask the server for fresh numbers every so often, say every minute or every five minutes. Developers call this polling. It is simple and reliable, and for most dashboards it is the right choice.

During an incident it has three weaknesses:

  • Everything arrives late, by up to one full interval.
  • Bursts get blurred. Six suspicious payments in two minutes look like an ordinary five-minute total.
  • When people panic and make it check more often, it piles extra load onto a system that is already under stress.
The six reported deposit sweeps on 29 Oct 2026, as seen by a five-minute poller (late and blurred) and by a WebSocket dashboard (immediate).
Fig. 01 — The reported sweep times, seen through a five-minute check versus a live connection.

The big idea: let the server push updates, but keep one source of truth

The alternative is a live connection, where the server pushes each event to the dashboard the moment it happens. The technology for this, WebSockets, is well supported in every modern browser.

Live connections bring two new risks: a flood of updates can make the page freeze, and if the connection drops for a moment, the dashboard can silently miss events. So the approach I use has one rule: the live connection is a fast hint about what changed, and the normal server data is still the truth.

How to do it

1. Start with a dashboard that works without live updates

The ordinary version, which loads data from the server, must work on its own. It is what a new tab shows first, and it is the safety net when the live connection drops.

2. Feed live updates into the same data

Live events update the same data the dashboard already shows, rather than a separate copy. In my projects, a library called TanStack Query holds that data, so every chart and table stays consistent.

3. Group updates so the page never freezes

Instead of redrawing the screen for every single event, the dashboard collects events for a quarter of a second and applies them together. A burst of 500 events becomes four smooth updates per second instead of 500 jerky ones. Duplicate events are ignored, so nothing is counted twice.

Architecture: WebSocket events are buffered and flushed into the TanStack Query cache; reconnects invalidate to resync from the API; alert decisions live in Zustand.
Fig. 02 — Live events update the dashboard's data in small batches; after a reconnect, it reloads the full picture from the server.

4. After any disconnection, reload the full picture

If the connection drops, the dashboard assumes it missed something. As soon as it reconnects, it reloads everything from the server. That one habit prevents the most dangerous kind of dashboard bug: a calm-looking screen that is quietly out of date.

5. Turn patterns into clear alerts

Simple rules compare what is happening now with what is normal, for example "outgoing payments in the last ten minutes are five times the usual rate". When a rule triggers, the alert appears at the top, and whoever is on call can acknowledge or mute it.

Takeaway

  • Keep regular checking for everyday dashboards. Use live updates where minutes matter.
  • Feed live updates into the same data the dashboard already uses, so everything stays consistent.
  • Group updates to keep the page smooth, ignore duplicates, and reload everything after a disconnection.
  • Turn patterns into clear alerts people can act on.

A dashboard will not stop an attack on its own. But every minute between the first warning sign and someone pressing the emergency stop costs money. Your dashboard should never be the slowest part of that response.

/OCCASIONAL_NOTES

Useful notes, when there’s something worth sharing.

A low-volume digest on product systems, interfaces, and technical work. Your email stays in Taiwo’s private portfolio list—no third-party tracking.