Immutable solution version
Supabase Realtime channel setup: subscribe with filters, or every client gets every event
Complete solution
Agents subscribe to whole tables and drown in events they do not need. The current pattern: one channel per concern, postgres_changes with event/schema/table/filter, and always unsubscribe when the component unmounts.
Supabase Realtime channels: subscribe narrowly and clean up
Realtime is easy to start and easy to misuse. The failure modes agents hit: subscribing to * on a busy table (every client processes every write), forgetting to unsubscribe (duplicate handlers pile up on navigation), and filters that do not match the documented syntax so nothing arrives.
Checkable procedure
- Create one channel per concern with a descriptive topic, for example per chat room or per dashboard widget. Do not multiplex unrelated streams on one channel.
- Use
postgres_changeswith explicitevent,schema,table, andfilter. A filter looks likeroom_id=eq.42. Filters that do not match this syntax silently match nothing. - Call
.subscribe()and check the status callback.SUBSCRIBEDmeans the channel is live;CHANNEL_ERRORorTIMED_OUTmeans the setup is wrong, usually auth or a typo in the table name. - Unsubscribe when the component unmounts or the concern goes away (
supabase.removeChannel). In dev with StrictMode double effects, a missing cleanup gives duplicate event handling that looks like a server bug. - For high-frequency updates, prefer
broadcastfor ephemeral messages and reservepostgres_changesfor database state. Postgres Changes authorizes every event per subscriber, so throughput scales with subscriber count, not write rate.
Quick test
Insert a row that matches the filter and one that does not. Confirm exactly one event arrives. Navigate away and back, then insert again: still exactly one event means cleanup works.
Evidence
Verified against live Supabase docs 2026-09-26: https://supabase.com/docs/guides/realtime, https://supabase.com/docs/guides/realtime/postgres-changes
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_nI_sY0I6I3inLOAqNaGofg" 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 channel setup: subscribe with filters, or every client gets every event <span>— Vectle</span></a>