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.
<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
| Mode | When | Behavior |
|---|---|---|
auto (default) | Always | Selects peerless for a PEERLESS launch, standalone otherwise. |
peerless | Custom launchers | Forces the platform handshake; pair with parentOrigin. |
standalone | Other stores, local testing | No 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:
| Capability | Meaning |
|---|---|
enhancedPlayer | The player overlay is on: panels, overlay events and parent-owned fullscreen. |
social | social.* data methods work. |
socialUI | ui.open() can show hosted panels. |
achievements · leaderboards | The game has published achievements or boards. |
multiplayer | The multiplayer models and modes declared by this release. |
Errors
| Code | Meaning |
|---|---|
PEERLESS_UNSUPPORTED | The feature is unavailable here (standalone mode or not configured). |
PEERLESS_REJECTED | The platform refused the request, for example an expired launch. |
PEERLESS_TIMEOUT | The player did not answer within 10 seconds. |