Presence

Track and sync who is connected to a channel.

JavaScript
const room = stitchdb.channel('room-1')
room.on('presence', { event: 'sync' }, () => console.log(room.presenceState()))
room.subscribe(async (status) => {
  if (status === 'SUBSCRIBED') await room.track({ user: 'ada', online_at: new Date().toISOString() })
})

track() shares the current client's state; presenceState() returns everyone's.