Back to work

Tic-Tac-Toe

A local tic-tac-toe game with board history, time travel, and result notifications.

Date
Mar 2026
Category
Games
Status
Live

Stack

  • Next.js
  • React
  • TypeScript
  • Tailwind CSS

Problem

The project implements tic-tac-toe for two players on the same device. The game had to alternate turns between X and O, detect three in a row or a draw, and let people review previous moves without losing the state.

Role

I developed the game with React 19 and Next.js 16: the component architecture, game state, winner calculation, history, and responsive styles.

Decisions

  1. State as a history of boards.

    The game is stored as a history array with the board for each move and a currentMove index. The visible board is history[currentMove], and the turn, winner, and draw are derived from that state instead of being duplicated.

  2. Board, square, and mini-board.

    Game holds the state; Board draws the grid and the current status; Square represents each cell; MiniBoard reuses the board in miniature for the history.

  3. Eight winning combinations.

    calculateWinner checks three rows, three columns, and two diagonals. A draw is declared when there is no winner and every cell is occupied.

  4. History accessible on mobile.

    The side panel is controlled by isHistoryOpen on small screens. Selecting a move restores that board, sonner announces the result, and the restart button returns the game to the beginning.

Result

The game alternates turns, detects wins and draws, shows the result with notifications, lets people travel through the history and restart, with a responsive board and cyan X against pink O on a dark background.