createWebSocketPresence
Share per-peer state that expires, for presence, live cursors and selections.
Available from both react-websocket and react-websocket/core. Render the peers with useWebSocketPresence. The guide is Presence and live cursors.
Usage
Annotate send's state parameter: that's what cursors.set() accepts.
Parameters
Returns
A WebSocketPresence<P>:
Behavior
- Volatile. Updates are sent with
volatile, so none is queued while disconnected; a new connection gets the current state from anopenlistener. - Expiry. A peer is removed
timeoutms after its last update, by a single timer for the next one due. - Connection. It doesn't open the connection;
useWebSocketPresenceholds it while mounted.