Skip to content

Guide · Open source

How to use boardgame.io: install, build and run a turn-based game

Updated · written with AI from the project's own documentation and checked against our catalogue data

boardgame.io is an open-source JavaScript and TypeScript engine for building turn-based games. You describe how the game state changes when a player makes a move, and the library turns those functions into a playable game with online multiplayer. This guide is for developers who want to install it, understand its core ideas and know when it fits their project.

boardgame.ioboardgameio/boardgame.io · ★ 12.5k · MIT

Quick start

  1. 1Check prerequisites. Make sure Node.js and npm are installed on your machine, as the README lists them as prerequisites.
  2. 2Install the library. Run npm install boardgame.io in your project folder to add the engine as a dependency.
  3. 3Read the documentation. Open the official documentation at boardgame.io/documentation to learn the game definition format.
  4. 4Write your moves. Write functions that describe how the game state changes when a player makes each move.
  5. 5Prototype the rules. Use the built-in interface to simulate moves before building a full user interface.
  6. 6Add a client binding. Attach the vanilla JS client or the React or React Native bindings to render the game.

What boardgame.io does and who it is for

boardgame.io is an engine, not a finished game. You write functions that describe how the game state changes when a particular move is made, and the library converts them into a game that can be played. According to the README, this includes online multiplayer and state syncing across clients and the server, so you do not write networking or storage code yourself.

It suits developers building turn-based board or card games for the browser, people prototyping rules before building a full interface, and developers using React or React Native who want a ready-made game client binding. It is not a good fit for real-time action games, because the project focuses on turn-based play, and it is used through code, so non-programmers will find it hard to use.

  • State management across clients, server and storage
  • Multiplayer state kept in sync
  • Automatically generated bots (AI)
  • Game phases with different rules and turn orders
  • Lobby for matchmaking and game creation
  • Prototyping interface to simulate moves before rendering
  • Plugin system for extending the engine
  • View-layer agnostic: vanilla JS client or React and React Native bindings
  • Game logs with time travel to earlier states

Install boardgame.io with npm

The README lists Node.js and npm as the prerequisites. Install the library from the npm registry in your project folder with the command below.

The full documentation at boardgame.io/documentation covers project setup in more detail.

npm install boardgame.io

Define the game state and moves

The core idea is that you write functions describing how state changes when a player makes a move. Each move receives the current state and returns the updated state, and the engine handles the rest, including keeping clients in sync.

The README does not include a full code example, so consult the documentation for the exact game definition format and API.

  • Write a move as a function that describes the state change
  • Let the engine manage syncing between clients and the server
  • Use game phases when different rules or turn orders apply

Prototype rules before building the interface

The library includes an interface for simulating moves before you render the game. This lets you test rule logic early, before investing in a full user interface.

Because the engine is view-layer agnostic, you can later attach the vanilla JS client or the React or React Native bindings.

Add multiplayer and lobby features

The README says game state is kept in sync in realtime and across platforms, and that a lobby handles player matchmaking and game creation. You do not need to write your own networking layer to get these features.

Use the official documentation and the project's Gitter channel or GitHub Discussions for questions about setting up multiplayer.

Learn the project's resources and get help

The main documentation is at boardgame.io/documentation. The project also has a changelog in docs/documentation/CHANGELOG.md, a Gitter channel, and GitHub Discussions. Bugs can be reported through GitHub issues.

To explore working code, the README says examples are in the examples folder of the repository. Run them with npm install followed by npm start from the repository root.

npm install npm start

What people use it for

  • Building a turn-based card game for the browser with online multiplayer
  • Prototyping the rules of a board game before designing its interface
  • Adding multiplayer and matchmaking to a React or React Native game without writing networking code
  • Creating a game with multiple phases that use different turn orders

Frequently asked questions

Is boardgame.io free to use?

Yes. The repository is licensed under the MIT License, as stated in the README's License section. Check the LICENSE file for the full terms.

What do I need to install boardgame.io?

The README lists Node.js and npm as prerequisites. Install the library with npm install boardgame.io.

Does boardgame.io handle multiplayer for me?

According to the README, yes. It keeps game state in sync across clients and the server, so you do not have to write networking or storage code yourself.

Can I use boardgame.io with React?

Yes. The README says you can use the vanilla JS client or the bindings for React and React Native.

Can boardgame.io make real-time action games?

No. The project is focused on turn-based play, so it is not intended for real-time action games.

Where can I get help with boardgame.io?

The README points to the full documentation at boardgame.io/documentation, the Gitter channel, and GitHub Discussions. You can also report bugs through GitHub issues.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

boardgame.io suits JavaScript or TypeScript developers who are building turn-based games and want multiplayer and state syncing without writing networking code. It is not a finished game, and it is not suited to real-time action games or to people who do not write code. If you need a ready-to-play game, or real-time gameplay, pick a different tool.

Install options & downloads