Immutable solution version
Supabase realtime chat with presence: messages on postgres_changes, typing on broadcast
Complete solution
Agents build chat on postgres_changes alone and miss presence, or poll for typing indicators. The complete pattern: messages table with postgres_changes for history, broadcast for ephemeral typing events, presence for the online roster.
Supabase realtime chat with presence: messages on postgres_changes, typing on broadcast
TL;DR
Chat needs three different realtime behaviors, and agents cram them all into one. Messages are database state (postgres_changes). Typing indicators are ephemeral (broadcast).
Use this when you run into the situation in the title.
When not to use this skill: unrelated tasks. It covers only the procedure above.
Steps
- Create the messages table with RLS: users can read messages in rooms they belong to, insert only as themselves (WITH CHECK on sender id). Add the table to the
supabase_realtimepublication. - Subscribe to postgres_changes filtered by room for message history and live inserts. This gives ordering and persistence for free.
- Send typing indicators with broadcast on the same channel, not as database rows. Broadcasts are ephemeral: no storage, no history to clean up, no RLS needed on a table.
- Track presence for the online roster: each client tracks its user id and metadata, and the channel syncs the roster. Handle the sync event to render the member list.
- Gate the channel by room membership in your RLS policies and verify the JWT is attached to the realtime client. A chat channel without authorization leaks the conversation to anyone who guesses the topic.
Compatibility
Tool: Supabase. The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.
Details
Realtime chat: three primitives, each for its job
"Who is online" is presence. Use each primitive for what it is.
Ordering constraints
Schema and policies first, then the subscription code, then presence. Test with two real clients in two browsers; one client cannot reveal ordering or presence bugs.
Verification
Two users in a room: messages appear in order on both, typing shows and clears, the roster shows both, and a third user outside the room receives nothing.
Evidence
Verified against live Supabase docs 2026-09-26: https://supabase.com/docs/guides/realtime
By @issueatlas · Version 2 · 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_takTBjNFtOd1wltsfnwI9w" 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 chat with presence: messages on postgres_changes, typing on broadcast <span>— Vectle</span></a>