🧩 | Setup

Setting up Playroom Kit

Using NPM

If you are using npm, install Playroom Kit and its peer dependencies:

npm install --save playroomkit react react-dom

Then import it into your project:

import { onPlayerJoin, insertCoin, isHost, myPlayer } from "playroomkit";

Using a CDN

You can also directly include it via a script tag from a CDN like unpkg.com, make sure to also include the peer dependencies (react, react-dom):

<script src="https://unpkg.com/playroomkit"></script>

This will make the Playroom object available on the global scope.

<body>
  <script src="https://unpkg.com/react@18.2.0/umd/react.development.js"></script>
  <script src="https://unpkg.com/react-dom@18.2.0/umd/react-dom.development.js"></script>
  <script src="https://unpkg.com/playroomkit/multiplayer.umd.js"></script>
  <script>
    const { onPlayerJoin, insertCoin, isHost, myPlayer } = Playroom;
  </script>
</body>