Developers

Developer SDK

Community games communicate with Browser Game Lab through a small postMessage protocol from a sandboxed iframe.

Message protocol

Do not call the leaderboard API directly from your iframe. Send messages to the parent page and let the Browser Game Lab bridge validate and submit scores.

Ready and resize

parent.postMessage({ type: "bgl:ready" }, "*");
parent.postMessage({ type: "bgl:resize", height: document.body.scrollHeight }, "*");

Score event

parent.postMessage({
  type: "bgl:score",
  score: 4200,
  mode: "standard",
  durationMs: 95000,
  metadata: { level: 3, build: "1.0.0" }
}, "*");

Score payload rules

  • score must be an integer within the approved range for your game.
  • mode must be one of the approved mode strings.
  • durationMs must be a realistic integer duration.
  • metadata may contain only small primitive fields such as level, build, mistakes, or accuracy.

Iframe sandbox

Approved community games run with scripts, pointer lock, fullscreen, and gamepad support. Same-origin access, popups, and forms are disabled by default.

Zip review checklist

  • Zip must include an index.html entry point.
  • No executable files, server-side code, hidden downloaders, or unreviewed ad SDKs.
  • External network calls, analytics, payment links, and sponsorship code must be disclosed.