boardgame.io
State Management and Multiplayer Networking for Turn-Based Games
A TypeScript framework for building turn-based multiplayer browser games, you write the rules and it automatically handles real-time sync, game state, lobbies, and AI opponents.
boardgame.io is a TypeScript and JavaScript framework for building turn-based games that run in a browser with online multiplayer support. The idea is that you describe your game by writing functions that define what moves are valid and how the game state changes after each move. The framework then handles everything else: keeping all players in sync over the network, storing game state, and running an AI opponent if you want one.
You do not write any networking code yourself. The framework manages real-time state synchronization across clients and a server automatically. This makes it practical to build something like chess, poker, or a custom card game without having to learn how websockets or databases work.
Other features include game phases (sections of a game with different rules or turn orders), a built-in lobby for matchmaking, and a prototyping mode where you can simulate moves before you have built any visual interface. There is also a time-travel log that lets you step back through previous game states to review what happened.
The framework is view-layer agnostic, meaning you can pair it with React, React Native, or plain JavaScript to draw the board and pieces. Installation is through npm, and the repository includes runnable examples to get you started quickly.
The README is short and points to separate full documentation on the project website for deeper learning. The project is MIT-licensed and welcomes contributions.
Where it fits
- Build an online multiplayer card or board game without writing any networking or websocket code.
- Prototype a turn-based game and simulate moves using the built-in prototyping mode before building any UI.
- Add an AI opponent to a browser game using the built-in random or MCTS AI strategies.
- Create a game lobby with matchmaking so players can create and join game rooms from a browser.