A real-time multiplayer chess game built with Node.js, Express, Socket.io, and Tailwind CSS. Play with friends using unique room codes instantly in your browser.
- Real-time Gameplay: Powered by Socket.io for instantaneous move syncing.
- Private Rooms: Create or join games using unique codes.
- Responsive Design: Optimized for both desktop and mobile devices.
- Game Controls: Surrender, Play Again, and easy Room Code sharing.
- Timers: Interactive game clocks for both players.
- Modern UI: Sleek dark-mode aesthetic with smooth animations.
Follow these steps to get the project running locally:
- Clone the repository:
git clone https://github.com/khaizinam/chess-online.git cd chess-online - Install dependencies:
yarn install
- Configure environment variables:
Edit
cp .env-sample .env
.envand provide your own values forPORT,GA_ID, etc.
- Development Mode (with auto-reload):
yarn watch
- Production Mode:
yarn start
The server will start on the port specified in your .env file (default: 3037).
If you are deploying to a production server using Nginx as a reverse proxy, you can use the provided nginx.conf as a template.
- Create a new Nginx configuration file:
sudo nano /etc/nginx/sites-available/chess-online
- Copy the content from
nginx.confand paste it into the file. Adjust theserver_nameto your domain. - Enable the configuration:
sudo ln -s /etc/nginx/sites-available/chess-online /etc/nginx/sites-enabled/
- Test and restart Nginx:
sudo nginx -t sudo systemctl restart nginx
Important
Make sure the proxy_pass port in Nginx matches the PORT defined in your .env file. The provided configuration includes necessary headers for WebSocket support (Upgrade, Connection).
- Movement: Standard chess rules apply.
- Winning: Checkmate the opponent or win if they run out of time.
- Surrender: You can choose to surrender at any time to end the game immediately.
- Draw: The game ends in a draw if the board reaching a standard draw position.
If you enjoy this project and would like to support its development, you can make a donation via the QR code below:
Thank you for your support! 💖
Developed and maintained by khaizinam.
- Website: khaizinam.io.vn
- GitHub: @khaizinam
