Crow NestDocs

Build apps

Live updates

There are two kinds of live updates:

  • Saved data that updates for everyone. Use watch on a collection: when anyone adds or changes a document, every open page gets the new list. See Data.
  • Messages that aren't saved. Cursors, typing indicators, game moves. Use a crow.live channel.

Turn on channels

json
{ "live": { "who": "viewers" } }

who is viewers (signed-in people who can open the app, the default) or public (signed-out visitors too, public apps only). Without a live section, watch still updates live for anyone who can read the collection; only channels need it.

Use a channel

js
const room = crow.live.channel("board");

room.on("message", (data, from) => move(data));   // from = { userId, visitor }
room.on("presence", (people) => showWho(people));  // who is in the channel now
room.send({ x: 10, y: 20 });                       // any JSON, up to 4 KB
room.leave();

Everyone in the same app who joins a channel with the same name gets each message. Messages aren't stored: someone who joins later doesn't see earlier ones. Save anything that should last with crow.db.