A real-time youtube sync application that lets multiple users to watch youtube videos together with synchronized playback and live chat.
Built with React, Express, Socket.IO, and the YouTube IFrame API.
Status: Active Development
Acknowledgement: This project is fork of yt-cowatch by GitUtk.
- Real-time synchronized YouTube playback
- Server-authoritative synchronization algorithm
- Automatic playback drift detection and correction
- Play, pause, seek, and video change synchronization
- Create and join rooms instantly
- Admin-controlled playback
- Live room chat
- Automatic room restoration after page refresh
- Persistent user identity using
clientId - Username persistence with Local Storage
- Shared room state across all participants
- Responsive UI
- Reusable UI components powered by shadcn/ui
- Modular React architecture using custom hooks
- React
- Vite
- shadcn/ui
- Tailwind CSS v4
- Context API
- Custom Hooks
- Socket.IO Client
- Node.js
- Express
- Socket.IO
- Frontend: Vercel
- Backend: Render
Admin
│
│ playback-control
▼
Server (Source of Truth)
│
├── maintains room playback state
├── calculates expected playback time
├── detects playback drift
└── sends playback-sync when required
│
▼
Participants
The server is responsible for maintaining the authoritative playback state, while clients periodically report their playback status. Participants are only resynchronized when playback drift exceeds the allowed threshold, reducing unnecessary synchronization events.
- Generate a unique room ID.
- The first participant automatically becomes the room admin.
ytsync uses a server-authoritative synchronization model.
- The room owner (admin) controls playback.
- The server maintains the authoritative playback state.
- Clients periodically report their playback status.
- The server calculates playback drift for every participant.
- Clients exceeding the allowed drift threshold are automatically resynchronized.
serverTimeis used to compensate for network latency when calculating the expected playback position.
This approach keeps playback synchronized even under unstable network conditions.
After refreshing the page:
clientIdis restored from Local Storage.- Username is restored automatically.
- The user rejoins the existing room.
- Room state is synchronized without creating duplicate users.
ytsync
│
├── frontend
│ ├── src
│ │ ├── components
│ │ ├── context
│ │ ├── hooks
│ │ ├── pages
│ │ ├── services
│ │ ├── utils
│ │ └── ui
│ └── public
│
├── backend
│ ├── server.js
│ ├── rooms.js
│ └── package.json
│
└── README.md
- Completely refactored project architecture
- Modular React component structure
- Extensive use of reusable custom hooks
- Dedicated Socket.IO service layer
- Improved Context API state management
- Automatic room restoration after refresh
- Persistent user identity using
clientId - Server-authoritative synchronization algorithm
- Playback drift detection and automatic correction
- Improved synchronization under network latency
- Reusable UI components with shadcn/ui
- Better maintainability and scalability
git clone https://github.com/manish-850/ytsync.git
cd ytsynccd frontend
npm install
npm run devcd backend
npm install
npm start- Room creation
- Join room
- Live chat
- Play synchronization
- Pause synchronization
- Seek synchronization
- Video change synchronization
- Server-authoritative synchronization
- Playback drift detection
- Automatic playback correction
- Automatic room restoration
- Persistent user identity
- Responsive UI
- shadcn/ui integration
- Playback buffering indicator
- Video queue / playlist
- Room permissions
- Persistent chat history
- Room expiration
- Mobile UI improvements
- Emoji reactions
- Theme switching
Contributions are welcome.
- Fork the repository.
- Create a feature branch.
git checkout -b feature/my-feature- Commit your changes.
git commit -m "feat: add awesome feature"- Push the branch.
git push origin feature/my-feature- Open a Pull Request.
git commit -m "feat: add awesome feature"Original project: https://github.com/GitUtk/yt-cowatch
This repository continues development with significant architectural improvements, redesigned synchronization logic, reusable UI components, and additional real-time features.
This project is licensed under the MIT License.