A two-player Tic Tac Toe game built with React and Vite.
- Two-player local gameplay (X and O)
- Win detection with highlighted winning cells
- Draw detection
- Score tracking across rounds
- Responsive — works on phones, tablets, and desktops
- React 19
- Vite 7
- Plain CSS (no UI libraries)
# clone the repo
git clone https://github.com/your-username/tic-tac-toe-reactjs.git
cd tic-tac-toe-reactjs
# install dependencies
npm install
# start the dev server
npm run devOpen http://localhost:5173 in your browser.
| Command | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Build for production |
npm run preview |
Preview the production build |
npm run lint |
Run ESLint |
src/
├── App.jsx # Game logic and UI
├── App.css # All styles
├── main.jsx # Entry point
└── index.css # Global reset
- X always goes first.
- Players alternate clicking empty cells.
- First to get three in a row (horizontal, vertical, or diagonal) wins.
- If all nine cells are filled with no winner, it's a draw.
- Click Play again to start a new round — scores carry over.