You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 22, 2025. It is now read-only.
A real-time collaborative cursor demo built with ActorCore and Next.js. This example demonstrates how to create a multi-user application where users can see each other's cursor positions in real-time.
4
+
5
+
## Features
6
+
7
+
- Real-time cursor position tracking across multiple browser tabs/windows
8
+
- Each user has a unique random ID, username, and color
9
+
- Cursor list showing all connected users with their coordinates
10
+
- Visual cursor pointers showing live cursor positions
11
+
- Efficient cursor movement with lodash-es throttling (16ms)
12
+
- Automatic cleanup when users disconnect
13
+
- Built with React, Next.js, and Tailwind CSS
14
+
15
+
## Getting Started
16
+
17
+
1. Install dependencies:
18
+
```bash
19
+
yarn install
20
+
```
21
+
22
+
2. Start both the development servers:
23
+
```bash
24
+
yarn dev
25
+
```
26
+
27
+
This will start:
28
+
- ActorCore server on port 6420
29
+
- Next.js development server on port 3000
30
+
31
+
3. Open multiple browser tabs/windows to `http://localhost:3000` to see the cursors interact
32
+
33
+
## How It Works
34
+
35
+
The application uses ActorCore's real-time communication features to:
36
+
37
+
1. Create a unique cursor for each connected client with a random color and username
38
+
2. Broadcast throttled cursor position updates (every 16ms) using lodash-es
39
+
3. Maintain a list of all active cursors with their positions
40
+
4. Remove cursors when clients disconnect
41
+
42
+
### Key Components
43
+
44
+
-`src/cursor-room.ts`: The ActorCore room that manages cursor state and communication
45
+
-`src/components/CursorList.tsx`: React component that displays the list of connected cursors
46
+
-`src/components/CursorPointers.tsx`: React component that renders the visual cursor indicators
47
+
-`src/components/App.tsx`: Main application component that handles cursor movement and updates
48
+
-`src/server.ts`: ActorCore server setup
49
+
50
+
## Architecture
51
+
52
+
The application follows a client-server architecture where:
53
+
54
+
1. The ActorCore server maintains the source of truth for cursor states
55
+
2. Clients send cursor position updates when their mouse moves (throttled with lodash-es)
56
+
3. The server broadcasts these updates to all other connected clients
57
+
4. Each client renders both the cursor list and visual cursor pointers
58
+
5. The UI is built with Next.js and styled with Tailwind CSS with a modern dark theme
59
+
60
+
## Development
61
+
62
+
To modify the example:
63
+
64
+
1. Edit `src/cursor-room.ts` to change cursor behavior or add new features
65
+
2. Modify `src/components/CursorList.tsx` to update the cursor list visualization
66
+
3. Modify `src/components/CursorPointers.tsx` to update the cursor pointer visualization
67
+
4. Update `src/components/App.tsx` to change how cursor movements are tracked
68
+
5. The server runs on port 6420 by default
69
+
70
+
## Dependencies
71
+
72
+
Key dependencies include:
73
+
-`actor-core`: For real-time state management
74
+
-`next`: For the React framework and development server
75
+
-`lodash-es`: For efficient cursor movement throttling
76
+
-`tailwindcss`: For styling
77
+
78
+
## License
79
+
80
+
This example is part of the ActorCore project and is available under the Apache 2.0 license.
Built with the ActorCore framework. This demo showcases real-time state synchronization across multiple users with automatic persistence and low-latency updates.
0 commit comments