A real-time 2-player chess game built with Next.js App Router, Socket.IO, and chess.js.
- Real-time multiplayer with Socket.IO
- Automatic color assignment (White, Black, or Spectator)
- Move sync across clients
- Game history & match results
- PostgreSQL + Prisma for persistent storage
git clone https://github.com/yourusername/multiplayer-chess-app.git
cd multiplayer-chess-app
npm installCreate a .env file:
JWT_SECRET=your_secret
DATABASE_URL=your_postgres_url- Make sure PostgreSQL is running
- Update your
.env:
DATABASE_URL="postgresql://USER:PASSWORD@localhost:5432/chess_app_db"- Install dependencies:
npm install @prisma/client prisma pg
npx prisma init
npx prisma db pushnpm run devVisit http://localhost:3000/game/vs-player/room1 in two browser tabs to test multiplayer.
- ✅ Real-time gameplay
- ✅ Color assignment
- ✅ Move sync
- ✅ Match history
- ✅ Play vs bot
- ✅ Responsive UI
How do I play with a friend?
Share a room URL (e.g., /game/vs-player/room1). Anyone with the link can join.
How does the database work? Prisma + PostgreSQL handles game data. See "Getting Started" for setup.
Contributions and suggestions are welcome! Feel free to open an issue or PR.
MIT

