0
Challenge · 39Realtime, AI & Motion

Supabase Realtime & subscription authz

Realtimeused in ~64% of apps

Realtime feels like magic until a candidate ships it wrong: they open a channel from the browser, subscribe to every row in the table, and call it 'live updates.' In the interview you'll be asked the one question that separates a demo from production — how do you stop a logged-in user from subscribing to someone else's data? The answer is not 'the frontend filters it.'

Core idea. Supabase Realtime is a server that pushes Postgres changes and presence/broadcast events over a websocket. The websocket is a SEPARATE authorization surface from your REST calls: subscribing to a channel does NOT automatically respect your table's Row Level Security. You must explicitly authorize subscriptions — enable RLS on the source table for Postgres Changes, and use Realtime Authorization (RLS policies on `realtime.messages`) for broadcast/presence channels — so a user only ever receives their own rows and only joins channels they're allowed to join.
Playground, this isn't a screenshot
current stateIDLE
idle→loading→success→error
what the user sees
No data yet
press Load feed to start a request
request log (top → bottom)
Press Load feed. Then press it again while loading to watch the first request abort.

idle → loading → success or error — every fetch moves through this machine. Re-trigger while loading and the older request is aborted so a stale response can never overwrite a newer one.

↑ play a little first, then dig in