Skip to content
PEERLESSDocs

SDK setup

Load the SDK, initialize it once and handle both PEERLESS and standalone launches.

Load the script

Copy peerless-sdk.js into your build and load it before your game code. Bundling it locally keeps the build self-contained and lets PEERLESS check it during review.

index.html
<script src="./peerless-sdk.js"></script>
<script type="module" src="./game.js"></script>

For editor autocompletion, add peerless-sdk.d.ts to your project. It declares window.Peerless with documentation for every method.

Initialize once

Call init() once at startup. Later calls return the same promise.

try {
  const context = await Peerless.init();
  if (context.mode === "standalone") {
    await connectYourExistingBackend();
  } else {
    await startWithPlatform(context);
  }
} catch (error) {
  // A refused or expired PEERLESS launch. Show it; never fall back to a guest.
  showLaunchError(error.message);
}

Modes

ModeWhenBehavior
auto (default)AlwaysSelects peerless for a PEERLESS launch, standalone otherwise.
peerlessCustom launchersForces the platform handshake; pair with parentOrigin.
standaloneOther stores, local testingNo platform requests at all.

The mode cannot change during a launch. A launch marker alone never grants access: the SDK verifies the parent page and completes a handshake first.

What init() returns

{
  mode: "peerless" | "standalone";
  protocol: number;
  room?: string | null;          // a relay room for this launch, if any
  capabilities: PeerlessCapabilities;
  runtime?: PlatformRuntime;     // identity and credentials (PEERLESS only)
  player?: { playerId, playerName, gameId, developerPlayerId, guest? } | null;
}

Check capabilities

Features depend on the player, the release and the game's configuration. Check them before showing a button:

CapabilityMeaning
enhancedPlayerThe player overlay is on: panels, overlay events and parent-owned fullscreen.
socialsocial.* data methods work.
socialUIui.open() can show hosted panels.
achievements · leaderboardsThe game has published achievements or boards.
multiplayerThe multiplayer models and modes declared by this release.

Errors

CodeMeaning
PEERLESS_UNSUPPORTEDThe feature is unavailable here (standalone mode or not configured).
PEERLESS_REJECTEDThe platform refused the request, for example an expired launch.
PEERLESS_TIMEOUTThe player did not answer within 10 seconds.