ShortPlay SDK
The SDK is optional and pre-1.0. ShortPlay never requires it to publish or to be featured —
the zero-integration baseline (an unmodified HTML5 bundle) already gets pause-on-swipe-away and
reflow-on-grow for free, because the host drives real visibilitychange/blur/focus events and
resizes your iframe. This has been the explicit stance since the first ShortPlay game jam: "not
mentioned in the rules… the SDK is never required"
(docs/125-game-jam-1-plan.md:53-58,109). Import it if it helps you; don't feel obligated to.
What exists today
import { ShortPlay } from './shortplay-sdk';
ShortPlay.game({
build(container, accent, dims) {
// construct your game into `container` at the given accent color + { w, h }
},
onFocus(focused) {},
onPause() {},
onResume() {},
onResize(w, h) {},
onStop() {},
});
ShortPlay.score(1200);
ShortPlay.event('level_complete', { level: 3 });
ShortPlay.game(def)— register your game. Calling this sends areadymessage to the host; until you call it, the host doesn't know your game finished loading.ShortPlay.score(value)— report a score to the platform. Silently dropped if it's not a finite number or exceeds the platform's sanity bound — never throws.ShortPlay.event(name, data?)— report an arbitrary named event with an optional small JSON payload (capped at 16 KB; an unserializable payload is dropped, not thrown).createShortPlay(options?)— the lower-level constructorShortPlayis built on; mainly useful for tests (it accepts an injectablewindow/root).- The lifecycle callbacks (
onFocus,onPause,onResume,onResize,onStop) — all optional, all described in full on Hosted-game contract → Lifecycle callbacks.
Full source, including the security model (source-identity + per-mount-nonce message
authentication — the SDK is DX, not the trust boundary):
app/games-sdk/shortplay-sdk.ts.
Distribution (v0)
There's no npm package yet. For now, the SDK is a single copyable TypeScript file — this docs site
serves the exact same file the platform's own first-party games import:
shortplay-sdk.ts. Drop it into your project and import it by
relative path, the same way every ShortPlay first-party game does today, e.g.:
// app/games-dev/snake/v1/snake.ts:13
import { ShortPlay } from '../../../games-sdk/shortplay-sdk';
An npm package (@shortplay/game-sdk) is on the roadmap
(docs/07-architecture-and-build-plan.md:142) but not shipped — the copyable file above is the
real, current distribution path.
Roadmap (not yet available)
These are not shipped. Nothing on this site or in the SDK gives you access to them today — they're named here only so you know they're planned, not so you build against them:
- Scores & leaderboards as a platform-hosted feature (today,
ShortPlay.score()reports a value; there is no leaderboard surface consuming it yet). - Multiplayer rooms.
- Phone-as-controller.
These are tracked on the eng-sdk-v1 roadmap line and drafted directionally (unratified) in
docs/128-sdk-multiplayer-device-wave.md — nothing there is available to build against yet.