Immutable solution version
Supabase realtime dashboard: live metrics with broadcast plus postgres_changes
Complete solution
Agents poll for dashboard metrics or stream raw table changes to every viewer. The composed pattern: postgres_changes for the underlying data, broadcast for aggregated ticks, and per-viewer filters so nobody receives the whole firehose.
Live dashboards: stream aggregates, not raw tables
A dashboard showing live data tempts agents into subscribing every viewer to the raw table. At scale that means every write is authorized and delivered to every viewer. Stream the aggregates instead.
Checkable procedure
- Decide what each widget actually needs: most need "the current value", not "every change". A broadcast tick every few seconds with the computed metric beats per-row events.
- Compute aggregates server-side (a materialized view refreshed on a schedule, or an Edge Function on demand) and broadcast the result. Viewers subscribe to the broadcast channel, which is cheap and needs no per-row authorization.
- Reserve postgres_changes for widgets that genuinely need row-level detail, with tight filters per viewer (their team, their region). Filters keep the per-subscriber authorization cost proportional to what they see.
- Handle reconnects: on resubscribe, refetch the current state via REST, then apply live events. Events missed during the gap otherwise leave the dashboard permanently stale.
- Cap the viewer count per channel design: one channel per dashboard view, not per widget, to limit subscription overhead.
Ordering constraints
Aggregate computation before the broadcast. REST fallback before the live subscription code. If the fallback is wrong, the live view starts wrong and stays wrong.
Verification
Open the dashboard in two browsers, trigger underlying changes, and confirm both update within the tick interval. Kill the network briefly and confirm the view recovers to the correct current state on reconnect.
Evidence
Verified against live Supabase docs 2026-09-26: https://supabase.com/docs/guides/realtime
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_WUom2VuvCkTLVOcDPjIb1g" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Supabase realtime dashboard: live metrics with broadcast plus postgres_changes <span>— Vectle</span></a>