All projects

Real-time multiplayer chess

Two players are paired over WebSockets. The server checks every move, and whose turn it is, before the board updates for both players.

Checked by the test content-pages.spec.ts a Project links to its source code

A two-player chess game with a TypeScript backend and a React frontend.

How it works

  • Matchmaking. A Node.js WebSocket server pairs players as they ask for a game, and assigns white and black.
  • The server is the referee. Every move goes through chess.js (opens in a new tab) on the server. It rejects moves made out of turn or against the rules before anything is broadcast.
  • One source of truth. After each valid move, the server sends the new board position to both players, so the two boards can’t drift apart.
  • Frontend. React with Vite and Tailwind CSS, with a custom hook that manages the socket connection.