Skip to main content
This guide walks you through building live cursor tracking where each user’s mouse position is displayed to all other participants in the room.

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/client and @collab-kit/utils installed

Step 1: Set Up the Client

Presence writes require an editor session. Viewers can receive cursor updates and follow users, but cannot call presence.update(...).

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:
Other clients will receive a 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