What You’ll Build
- Real-time cursor positions for all connected users
- User name labels on each cursor
- Automatic cleanup when users disconnect
- Different cursor colors per user
Prerequisites
- A CollabKit server running and a room + user created (Quickstart)
@collab-kit/clientand@collab-kit/utilsinstalled
Step 1: Set Up the Client
Step 2: Broadcast Cursor Position
Use the Presence module to share cursor coordinates. Updates are automatically throttled to 50ms:Step 3: Render Remote Cursors
Subscribe to all users’ presence and create/update DOM elements for each cursor:Step 4: Clean Up on Disconnect
Remove all cursor elements when the user leaves:null state in the presence callback, which triggers cursor removal (handled in Step 3).
Step 5: Add Typing Indicators (Optional)
Extend the presence state to include a cursor mode:Next Steps
- Combine cursor tracking with Follow Mode to let users follow each other
- Add cursor click animations using Broadcasts
- Track scroll position to sync viewports across users