Quickstart
Add live cursors to your React app in under 5 minutes.
1. Start the server
The Flock server handles all the WebSocket connections. Run it locally with npx (no install needed):
Or with Docker:
The server starts on port 8787 by default. You should see:
2. Install the React package
3. Add cursors to your app
Wrap your app (or just the page that needs cursors) in <FlockProvider>, then call useCursors() to render other users' cursor positions:
Open this page in two browser tabs and move your mouse — you'll see each tab's cursor in the other.
4. Track mouse movement
By default, Flock tracks the mouse relative to the viewport and normalizes positions to 0–1 so cursors line up across different screen sizes. No extra code needed — the provider handles it.
To track within a specific element (like a canvas):
Try it live
Open this page in two browser tabs and move your mouse in the area below:
If the demo shows "Server not available", start the server locally first (npx @xevrion/flock-server) and set NEXT_PUBLIC_FLOCK_SERVER_URL=ws://localhost:8787 in apps/docs/.env.local.
Next steps
- See the canvas demo — standalone demo with cursors and presence
- Concepts — rooms, presence, and cursor data explained
- Self-hosting guide — Docker Compose setup with Redis
- API reference — full TypeScript API