StoicBuilder

HandbookII the ForumRealtime updates

IIthe Forum, The shape of an app

Realtime updates

1 min readUpdated 28 November

In plain words

Realtime keeps a live connection open between the browser and the server, so changes, such as a new comment or a like, appear on everyone's screen within moments.

Where you see it

Chirp's like counter ticking up while you watch, or a new message appearing in Guildhall's chat. In Supabase this is called Realtime: the browser subscribes to a table and hears about new or changed rows. Underneath it's usually a WebSocket, a connection that stays open instead of closing after each reply.

src/hooks/useLiveFeed.tsbrowser
const channel = supabase .channel("feed") .on("postgres_changes", { event: "INSERT", schema: "public", table: "posts" }, (payload) => setPosts((prev) => [payload.new, ...prev])) .subscribe(); // when the screen closes: supabase.removeChannel(channel);
Each new row in posts arrives as a message, and the feed puts it on top.

What goes wrong

  1. Subscribing without ever unsubscribing

    A screen that opens a new subscription each time it appears, and never closes the old one, ends up with several listeners. Each message then arrives several times.

  2. Realtime never switched on for the table

    In Supabase, a table only broadcasts changes once it's added to Realtime. The code looks right and nothing ever arrives.

  3. Realtime where a refresh would do

    A live connection for every visitor costs money and adds moving parts. A chat needs it; an order history rarely does.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Only add realtime where people need to see other people's changes within seconds. Unsubscribe when the screen closes, apply the same access rules as normal queries, and tell me which tables have realtime turned on.

Quick check

Sign in to earn +10 XP for it

Every new message in Guildhall's chat appears three times. What went wrong?

Got a prompt that touches realtime updates?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.