Getting started
Install the SDK in a browser game, call connect() during startup, and wait for
it before using Plot features. The first release will return a small client that
only confirms the connection.
Pre-release status:
@plot.game/sdk@0.1.0is not on npm yet. The install and CDN examples below will work after the first package publication.
Install with npm
Import the default SDK object and connect during game startup:
Normal games do not need connection options. PlotSDK.connect() is safe to call
more than once, and a failed attempt can be retried.
Your game is loaded inside Plot. Opening the game URL directly in a browser tab
is useful for ordinary UI work, but connect() will reject because there is no
Plot session around it.
Show a useful connection state
Connect before showing controls that depend on Plot, and handle failure as part of the game's startup screen:
Use the stable error code for logic. The message is intended to help a
developer diagnose the problem. See
PlotConnectionErrorCode for the
complete list of codes.
Use a browser script
A game without a package manager can load the IIFE build from a CDN. Pin the complete package version so a published game never changes underneath you:
The CDN URL will become available after the first npm release. Every release
includes dist/integrity.json; copy its SHA-384 value when updating the pinned
version.
Published games should always pin the complete SDK version, whether the SDK is installed from npm or loaded from a CDN. Continue with local development, or read the full API reference.