> Site index for LLMs: https://www.nandan.fyi/llms.txt

# Chess Online

> A web chess interface with real-time multiplayer, AI opponent, and drag-and-drop board - built to test and play chess in the browser.

- Published: 2022-08-20
- Source: https://github.com/nandan-varma/chess-online
- Live: https://chess.nandanvarma.com
- Canonical: https://www.nandan.fyi/projects/chess

I wanted a place to play chess online without ads, trackers, or accounts - and I wanted to be able to drop in my own chess AI. So I built the board and the platform myself.

## Features

- Play against a friend in real time - game state syncs instantly via Firebase Realtime Database
- Play against an AI opponent (js-chess-engine under the hood)
- Drag-and-drop piece movement
- Board-only mode for casual play or analysis

## Key decisions

- **Firebase over raw WebSockets** — real-time sync and auth came bundled without managing connection state or writing a game server; for a two-player board game the latency requirements are met by Realtime Database without custom infrastructure
- **Delegated move validation to js-chess-engine** — correctly validating chess moves (pins, en passant, castling, check detection) is roughly 2000 lines of fiddly edge cases; the library is tested and correct; the board UI shouldn't duplicate that logic
- **React DnD over native HTML5 drag-and-drop** — cross-browser touch support and clean mid-drag cancellation; the native API has inconsistent behaviour across browsers and no good model for rejecting a drop

## Future directions

- Login system and win/loss history
- Stronger engine (Stockfish via WASM)

## Built with

- [TanStack Start](https://tanstack.com/start)
- [React DnD](https://react-dnd.github.io/react-dnd/)
- [Firebase](https://firebase.google.com) - Realtime Database and Auth
- [tailwindcss](https://tailwindcss.com)
- Deployed on [Vercel](https://vercel.com)
