Back to Rivet

Real-time Collaborative Cursors

examples/cursors/README.md

2.2.11.1 KB
Original Source

Real-time Collaborative Cursors

Example project demonstrating real-time cursor tracking and collaborative canvas.

Getting Started

sh
git clone https://github.com/rivet-dev/rivet.git
cd rivet/examples/cursors
npm install
npm run dev

Features

  • Real-time cursor tracking: Broadcast cursor positions to all connected users instantly
  • Event-driven architecture: Use actor events to push updates to WebSocket clients
  • Persistent canvas state: Text labels automatically saved in actor state across sessions
  • Multiple rooms: Each room is a separate actor instance with isolated state

Implementation

This example demonstrates real-time collaboration using WebSockets and Rivet Actors:

  • Actor Definition (src/backend/registry.ts): Implements the canvasRoom actor for tracking cursor positions and managing collaborative canvas state

Resources

Read more about WebSockets, state, and events.

License

MIT