npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

board-game-engine-react

v2.0.0

Published

React library for using board-game-engine

Readme

Board Game Engine React

React library for running games built with board-game-engine. Renders shared boards, personal boards, choices, and game status; connects to a game server or runs in single-player mode.

For game rules, state shape, and engine concepts, see the board-game-engine package.


Install

npm install board-game-engine-react react

API

Game

Root UI component. Renders the current game state (shared board, personal boards, abstract choices, status). Pass a gameConnection object from useGameserverConnection.

import { Game, useGameserverConnection } from 'board-game-engine-react'

function App() {
  const gameConnection = useGameserverConnection({
    server: 'https://your-server.com',
    matchID: 'room-1',
    gameRules: myGameRules,
    credentials: '…',
    playerID: '0',
    numPlayers: 2,
  })

  return (
    <Game
      gameConnection={gameConnection}
      loading={<div>Connecting…</div>}
      isSpectator={false}
    />
  )
}

Single-player (no server): omit server, matchID, and credentials and pass gameRules and numPlayers:

const gameConnection = useGameserverConnection({
  gameRules: myGameRules,
  numPlayers: 2,
})

| Prop | Type | Description | |-------------------|---------|-------------| | gameConnection | object | Connection/state object (e.g. from useGameserverConnection). | | loading | node | Rendered while there is no game state (e.g. connecting). | | isSpectator | boolean | If true, disables making moves. |


useGameserverConnection(options)

Hook that creates and maintains a connection to a game server (or a local game when no server is configured). Returns an object that includes connection state and methods; pass this object as gameConnection to <Game />.

| Option | Type | Description | |-------------------|---------|-------------| | server | string | Game server URL (required for multiplayer). | | matchID | string | Room/match id (required for multiplayer). | | credentials | string | Auth credentials for the client (required for multiplayer). | | gameRules | object | Game definition from board-game-engine. | | boardgameIOGame | object | boardgame.io game config (alternative to gameRules). | | gameName | string | Game name sent to server. | | playerID | string | Player id (e.g. '0', '1'). | | numPlayers | number | Number of players. | | multiplayer | boolean | Use server multiplayer; omit or false for local/single-player. | | debug | boolean | Enable debug logging. | | enabled | boolean | If false, skip connecting (default: true). |


Styles

Import the default styles so the game UI looks correct:

import 'board-game-engine-react/dist/board-game-engine-react.css'

Further reading