Presence
Who's here, live cursors and typing, typed by your schema.
Presence is who's on a channel right now and a small state for each of them. Join with state, update it with a shallow merge, and leave when the connection closes; anyone who joins later gets a full snapshot. Identity comes from the signed token, so nobody can claim to be someone else.
Type the state
Presence state is typed by the same schema as your events. Keep it small: a name, what someone is doing, where their pointer is.
Join, update, leave
membershas one entry per connection, so a user with two tabs appears twice. Each hasconnectionId,user(from the token),stateandself.updatemerges into this tab's state. Pass the whole object or just what changed.- Leave the state out to watch who's here without joining:
Live cursors
LiveCursors shares your pointer over its children and draws everyone else's on top. Positions are 0 to 1 across that area, so different window sizes line up, and they're smoothed between updates so cursors glide instead of jumping. Movement never re-renders React, and drawing stops while nobody moves.
For your own cursor UI, useSmoothCursors runs the same smoothing and calls you with each position to draw. The smoother on its own is CursorSmoother in @anishroy/pulse/cursor, with no framework or DOM.
Typing
useTyping keeps a typing flag in presence: call notify on input and it clears itself a few seconds after the last keystroke.
Update rate
A connection sends at most 10 presence updates a second, which is already smooth once cursors are interpolated. Faster updates aren't dropped: they're merged, and the newest state always goes out, so a cursor ends exactly where it stopped. To send fewer, lower the rate (1 to 10):
A connection that keeps sending far more than the limit is closed and can't rejoin that channel for a minute.
Limits
- Up to 1,000 members per channel.
- Up to 10 updates a second per connection.
Presence keeps only the newest state. When every step matters (chat messages, strokes in a drawing, game moves), publish events instead: they're ordered, stored and replayed.