Skip to content

Documentation

Realtime

Listen to database changes, send messages between clients and see who is online. The supabase-js channel API, unchanged.

Database changes

Add a table to the realtime publication from the table editor or the Realtime page, then subscribe to inserts, updates and deletes.

const channel = vulcbase  .channel("room-changes")  .on("postgres_changes", { event: "INSERT", schema: "public", table: "messages", filter: "room_id=eq.42" }, (payload) => {    console.log("new message", payload.new);  })  .subscribe(); // stop listeningvulcbase.removeChannel(channel);

Row Level Security applies

A client only receives changes for rows its role may read. A user cannot receive rows that a select policy would hide from them. Make sure the table has policies before you rely on realtime for private data.

To get the old row on updates and deletes, set the table's replica identity to full: alter table messages replica identity full;

Broadcast

Send small messages to everyone on a channel without touching the database. Good for cursors, typing indicators and live events.

const room = vulcbase.channel("room:42", { config: { broadcast: { self: false } } }); room.on("broadcast", { event: "cursor" }, ({ payload }) => draw(payload.x, payload.y)).subscribe(); room.send({ type: "broadcast", event: "cursor", payload: { x: 412, y: 96 } });

Presence

Track which clients are connected and share a small piece of state for each.

const room = vulcbase.channel("room:42", { config: { presence: { key: user.id } } }); room  .on("presence", { event: "sync" }, () => console.log(room.presenceState()))  .subscribe(async (status) => {    if (status === "SUBSCRIBED") await room.track({ name: "Ana", typing: false });  });

Good to know

  • Realtime connects over WebSocket to /realtime/v1 on your project URL. supabase-js does this for you.
  • Each client authenticates with the user's access token, so the same policies apply as for REST.
  • Realtime messages are not stored. If a client is offline it will not receive them later; read the table to catch up.
  • Realtime activity shows in the Logs page.