CodeCollab is a real-time collaborative code editor that allows multiple users to write and edit code simultaneously. With built-in live preview for web languages, syntax highlighting powered by Monaco Editor, and optional GitHub integration, it's perfect for pair programming, coding interviews, teaching, or collaborative development.
- 🚀 Zero Setup for Collaborators - Share a room link and start coding instantly
- 🎨 Clean & Minimal UI - Distraction-free interface with blue and white theme
- ⚡ Real-time Sync - See changes as they happen with WebSocket technology
- 🌐 Live Preview - Instant preview for HTML, CSS, and JavaScript
- 🔒 Beginner Friendly - No complex configuration required
- 💾 Optional GitHub Integration - Save your work as GitHub Gists
-
✅ Real-time Collaboration
- Multiple users can code together in the same room
- See active users and their online status
- Automatic room creation and joining
- Live cursor tracking and code synchronization
-
✅ Monaco Editor Integration
- Powered by VS Code's editor engine
- IntelliSense and auto-completion
- Syntax highlighting for all major languages
- Customizable themes (Dark, Light, High Contrast)
-
✅ Live Preview Panel
- Real-time HTML rendering
- JavaScript console output capture
- CSS preview with demo elements
- Error handling and display
-
✅ Multi-Language Support
- JavaScript
- TypeScript
- Python
- Java
- C++
- HTML
- CSS
- JSON
-
✅ User Management
- Automatic username generation
- Active users list
- Connection status indicators
- User avatars
- 🔧 GitHub Integration
- Save code as private GitHub Gists
- Version control integration
- Easy sharing via Gist URLs
- React.js (v18.2.0) - UI framework
- Monaco Editor - Code editor component
- Socket.io-client - Real-time communication
- React-Split - Resizable panels
- Axios - HTTP client
- Node.js - Runtime environment
- Express.js - Web framework
- Socket.io - WebSocket server
- CORS - Cross-origin resource sharing
- Nodemon - Auto-restart server
- Create React App - React boilerplate
- dotenv - Environment variables
Before you begin, ensure you have the following installed:
- Node.js (v14.0.0 or higher)
- npm (v6.0.0 or higher)
- Git (optional, for cloning)
node --version
# Should output: v14.0.0 or higher
npm --version
# Should output: v6.0.0 or higherIf not installed, download from nodejs.org
# Clone the repository
git clone https://github.com/yourusername/code-collab.git
# Navigate to project directory
cd code-collabFollow the project structure to create all files as shown in the Project Structure section.
# Navigate to server directory
cd server
# Install dependencies
npm installInstalled packages:
- express
- socket.io
- cors
- dotenv
- axios
- nodemon (dev dependency)
# Navigate to client directory (from project root)
cd client
# Install dependencies
npm installInstalled packages:
- react & react-dom
- @monaco-editor/react
- socket.io-client
- axios
- react-split
You need to run both the server and client simultaneously.
cd server
npm run devExpected output:
[nodemon] starting `node src/server.js`
Server running on port 5000
cd client
npm startExpected output:
Compiled successfully!
You can now view code-editor-client in the browser.
Local: http://localhost:3000
On Your Network: http://192.168.x.x:3000
Note that the development build is not optimized.
To create a production build, use npm run build.
# In project root
npm init -y
npm install concurrently --save-devAdd to package.json in root:
{
"scripts": {
"server": "cd server && npm run dev",
"client": "cd client && npm start",
"dev": "concurrently \"npm run server\" \"npm run client\""
}
}Then run:
npm run devCreate start.sh in root:
#!/bin/bash
cd server && npm run dev &
cd client && npm startMake executable and run:
chmod +x start.sh
./start.shPress Ctrl + C in each terminal window to stop the servers.
code-editor/
│
├── client/ # React Frontend Application
│ ├── public/
│ │ ├── index.html # HTML template
│ │ └── favicon.ico # App icon
│ │
│ ├── src/
│ │ ├── components/
│ │ │ ├── Editor/
│ │ │ │ ├── CodeEditor.jsx # Main code editor component
│ │ │ │ ├── CodeEditor.css
│ │ │ │ └── LanguageSelector.jsx # Language dropdown
│ │ │ │
│ │ │ ├── Preview/
│ │ │ │ ├── LivePreview.jsx # Live preview panel
│ │ │ │ └── LivePreview.css
│ │ │ │
│ │ │ ├── Collaboration/
│ │ │ │ ├── CollaborationPanel.jsx # Collaboration features
│ │ │ │ ├── CollaborationPanel.css
│ │ │ │ ├── ActiveUsers.jsx # Active users list
│ │ │ │ └── ActiveUsers.css
│ │ │ │
│ │ │ ├── GitHub/
│ │ │ │ ├── GitHubPanel.jsx # GitHub integration (optional)
│ │ │ │ └── GitHubPanel.css
│ │ │ │
│ │ │ ├── Layout/
│ │ │ │ ├── Header.jsx # App header
│ │ │ │ └── Layout.css
│ │ │ │
│ │ │ └── Common/
│ │ │ ├── Button.jsx # Reusable button component
│ │ │ └── Button.css
│ │ │
│ │ ├── hooks/
│ │ │ ├── useCollaboration.js # Collaboration logic hook
│ │ │ └── useCodeExecution.js # Code execution hook
│ │ │
│ │ ├── services/
│ │ │ ├── socket.js # Socket.io client service
│ │ │ └── githubService.js # GitHub API service (optional)
│ │ │
│ │ ├── utils/
│ │ │ ├── languageConfig.js # Language configurations
│ │ │ └── constants.js # App constants
│ │ │
│ │ ├── styles/
│ │ │ └── global.css # Global styles
│ │ │
│ │ ├── App.jsx # Main App component
│ │ ├── App.css # App styles
│ │ └── index.js # React entry point
│ │
│ ├── package.json # Client dependencies
│ ├── .env # Environment variables
│ └── .env.example # Environment template
│
├── server/ # Node.js Backend Application
│ ├── src/
│ │ ├── socket/
│ │ │ └── socketHandler.js # Socket event handlers
│ │ │
│ │ ├── services/
│ │ │ └── collaborationService.js # Collaboration logic
│ │ │
│ │ └── server.js # Main server file
│ │
│ ├── package.json # Server dependencies
│ ├── .env # Environment variables
│ └── .env.example # Environment template
│
├── .gitignore # Git ignore file
├── README.md # This file
└── LICENSE # MIT License
| File | Purpose |
|---|---|
client/src/App.jsx |
Main React component, handles state and layout |
server/src/server.js |
Express server with Socket.io integration |
client/src/services/socket.js |
WebSocket client service |
client/src/components/Editor/CodeEditor.jsx |
Monaco editor wrapper |
client/src/components/Preview/LivePreview.jsx |
Live preview iframe handler |
client/src/hooks/useCollaboration.js |
Real-time collaboration logic |
- Open the application at
http://localhost:3000 - You'll be automatically assigned:
- A random username (e.g., "User123")
- A unique room ID (e.g., "room-abc123")
- Start coding immediately!
Method A: Share Room URL
- Copy the URL from your browser (e.g.,
http://localhost:3000?room=room-abc123) - Send it to your collaborators
- They open the link and join your room automatically
Method B: Share Room ID
- Click the "Copy" button in the Collaboration panel
- Send the room URL to others
- They can paste it in their browser
- Use the dropdown in the editor toolbar
- Select from: JavaScript, TypeScript, Python, Java, C++, HTML, CSS, JSON
- The editor will update syntax highlighting
- All collaborators will see the language change
For HTML:
- Write HTML code
- See instant preview in the right panel
- Includes CSS and JavaScript if embedded
For JavaScript:
- Write JavaScript code
- See
console.log()output in preview - Errors are displayed in red
For CSS:
- Write CSS rules
- See styled demo elements
- Preview updates in real-time
Note: Live preview only works for HTML, CSS, and JavaScript
-
Create a GitHub Personal Access Token:
- Go to https://github.com/settings/tokens
- Click "Generate new token (classic)"
- Select scope:
gist - Copy the token
-
In CodeCollab:
- Click the "GitHub" tab
- Paste your token
- Click "Save Token"
- Enter filename and description
- Click "Save as Gist"
-
View your Gist:
- Click the provided link
- Share with others
- Fork or clone as needed
Active Users List:
- See all users in the room
- Your name is highlighted
- Green dot indicates online status
Real-time Sync:
- Code changes sync instantly
- Language changes sync automatically
- All users see the same content
Room Persistence:
- Rooms exist as long as users are connected
- Code is preserved during the session
- Last user leaving clears the room
# Server Port
PORT=5000
# Client URL (for CORS)
CLIENT_URL=http://localhost:3000
# GitHub Integration (Optional)
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret# API Endpoints
REACT_APP_SOCKET_URL=http://localhost:5000
REACT_APP_API_URL=http://localhost:5000
# GitHub (Optional)
REACT_APP_GITHUB_OAUTH_URL=https://github.com/login/oauth/authorizeEdit client/src/utils/constants.js:
export const THEMES = {
DARK: 'vs-dark', // Default
LIGHT: 'light',
HC_BLACK: 'hc-black'
};Edit client/src/App.jsx:
const [language, setLanguage] = useState('javascript'); // Change to 'python', 'html', etc.Edit client/src/styles/global.css:
:root {
--primary-blue: #2563eb; /* Change primary color */
--primary-blue-dark: #1e40af;
/* ... other colors */
}This project is licensed under the MIT License.
MIT License
Copyright (c) 2024 CodeCollab
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
See LICENSE file for details.
Made with ❤️ by developers, for developers