A real-time collaborative whiteboard built with the MERN stack and Socket.IO for live drawing and cursor sharing between users — without any authentication. Just share a room code and draw together!
This project is a whiteboard web application that allows multiple users to join a shared room and draw together in real time. Users can join rooms by entering simple alphanumeric codes, and all drawing and cursor movements are synchronized across connected users instantly.
| Layer | Technology |
|---|---|
| Frontend | React.js |
| Backend | Node.js + Express |
| Database | MongoDB |
| Real-time | Socket.IO |
| Styling | Tailwind CSS / CSS |
- Enter a 6–8 character alphanumeric room code to join
- No login or registration required
- If room doesn't exist, it gets created dynamically
- Pencil tool (black, red, blue, green)
- Adjustable stroke width with slider
- Clear canvas button
- Smooth line drawing using HTML5 Canvas
- Live drawing sync across all connected users
- Real-time cursor tracking with unique user colors
- Live user count for each room
- All tabs stay in sync
project-root/ ├── client/ # React frontend │ ├── src/ │ │ ├── components/ │ │ │ ├── RoomJoin.jsx │ │ │ ├── Whiteboard.jsx │ │ │ ├── DrawingCanvas.jsx │ │ │ ├── Toolbar.jsx │ │ │ └── UserCursors.jsx │ │ ├── socket.js │ │ └── App.js │ └── package.json ├── server/ # Express + Socket.IO backend │ ├── models/ │ │ └── Room.js │ ├── routes/ │ │ └── roomRoutes.js │ ├── socket/ │ │ └── socketHandlers.js │ ├── server.js │ └── package.json ├── README.md
- Node.js (v16 or above)
- MongoDB (local or Atlas)
- npm or yarn
git clone https://github.com/your-username/collab-whiteboard.git
cd collab-whiteboardcd server
npm installCreate a .env file inside the server/ directory:
PORT= 8000 <br/>
MONGODB_URI=your mongoDB connection stringcd ../client
npm installCreate a .env file inside the client/ directory:
VITE_BACKEND_URL=http://localhost:8000npm run dev| Method | Endpoint | Description |
|---|---|---|
| POST | /api/rooms/join |
Join or create a room |
| GET | /api/rooms/:roomId |
Get room details |
Example POST Request
POST /api/rooms/join
Content-Type: application/json
{
"roomId": "abc123"
}- join-room — join a room by roomId
- cursor-move — send mouse position
- draw-start — begin a drawing stroke
- draw-move — continue drawing
- draw-end — finish the stroke
- clear-canvas — clear the canvas for all users
- user-count — receive updated number of active users
- cursor-update — receive cursor positions from others
- draw-start — begin stroke from another user
- draw-move — receive stroke path data
- draw-end — end stroke
[Client Browser]
↓ Socket.IO
[React App - Frontend]
↓ API & Socket.IO
[Express Server - Backend]
↓
[MongoDB] (optional for persistence)- Deploy Backend Use platforms like:
- vercel
- Render
- Railway
- [VPS or Docker Hosting]
Ensure:
- WebSocket transport enabled (transports: ['websocket'])
- CORS properly configured
- MongoDB URI (Atlas recommended) in environment
Example .env for production:
PORT=8000
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/whiteboard- Deploy Frontend Use:
- Vercel
- Netlify
Set env VITE_BACKEND_URL=https://your-backend-url.com in your .env.production.
- MongoDB Atlas
- Create a cluster on MongoDB Atlas
- Whitelist your backend IP
- Replace local URI with Atlas URI in .env
- Join/Create room via code
- Real-time drawing sync
- Cursor sync
- Multi-tab sync
- Clear canvas across all clients
- Active user tracking
📝 License MIT © 2025 Amisha