Skip to content

The Playspace SDK

The SDK's docs, topic by topic

Playspace plays your work from a link, inside one player that is the same for every work: on Playspace its Home button freezes it underneath, mutes it, closes it with an end card when it really ends, and shows what to play next. The SDK is the small contract between your code and that player. It comes with every page Playspace serves, as window.playspace, so you load nothing.

Make it with any engine or none: three.js, Babylon.js, PlayCanvas, Phaser, PixiJS, Construct, Godot, Unity or plain code. The engine is your tool; the web build it exports is what Playspace plays.

For developers and agents

Building with an AI agent, or want the exact names? Give your agent llms.txt, which lists every page of the SDK's docs as plain text; the four files under it are the whole contract, kept in step with the SDK every page gets. Where they and this page disagree, CONTRACT.md wins.

  • /llms.txt The index for an agent: every topic and starter page of the SDK's docs, as Markdown, one line each.
  • /sdk/CONTRACT.md The contract: every name on window.playspace, what it means, and which names stay.
  • /sdk/COOKBOOK.md The cookbook: how real works were wired onto the SDK, row by row, and the control manifest.
  • /sdk/playspace.d.ts The types, for TypeScript: window.playspace typed, so a wrong call fails your build.
  • /sdk/playspace.schema.json playspace.json's JSON Schema: every field read, with what Playspace does with it.

Start from the kit

The quickest way to a work that plays well here: start from one of the kit's three starters, small finished works already wired for Playspace. Each zip holds a starter's folder and its guide (AGENTS.md, the same as CLAUDE.md), written for you or your AI assistant: read it first.

Play the starters on Create

From your AI assistant

Add Playspace to your own Claude or ChatGPT as a connector, with the address below, and ask it to make a work. It starts from the kit, signs you in to Playspace the first time, and sends what it made here as a draft. Nothing is published until you review it and press Publish on Playspace. Claude Code and Codex take the same address, with a token you make on Create, in Make with AI. Playspace receives only the files your assistant sends as a draft; it never sees your chats.

https://www.joinplayspace.com/mcp

When the checks pass, your assistant gives you the review link and the address where your draft will play. Open the review in your own browser, signed in, and press Play your draft: it plays in the real player at that address, only for you, for a day. Before that press the address does not show your draft, and your assistant can never open it.

From a terminal, or from an AI coding tool in your own project: npx playspace publish followed by the folder. The first time, it opens a Playspace page in your browser to sign in. It uploads the folder and prints the review link once the checks pass; Publish stays yours. An AI tool adds --json and follows the checks with npx playspace status and --wait.

The steps for each, on Create

Your work already works: give it the player

A web work that runs in a browser on a computer runs on Playspace as it is: upload the folder with your index.html and it works with your own keys and mouse. You add nothing to be published.

A few calls give your work the rest of the player. Put each where the moment happens in your code. Each is safe to leave out, and each does nothing outside Playspace when you guard it on window.playspace. Use only the ones your work has: a piece with no goal and no ending needs start() and perhaps moment(), nothing more.

const ps = window.playspace; // present on every page Playspace serves: guard on it so your code runs anywhere

function begin() {
  // ... your own setup ...
  if (ps) ps.start(); // someone started: the first touch, a new run, a new scene
}

function onPresetChosen(name) {
  if (ps) ps.moment("preset_changed", { preset: name }); // a moment in your own words, recorded for you
}

function onFinish(points) {
  // only if your work really ends: a finish line, a story's last scene
  if (ps) ps.end({ score: points }); // the end card, the leaderboard when there is a score, Up next
}

function onSave(state) {
  localStorage.setItem("save", JSON.stringify(state)); // your own save still works
  if (ps) ps.save(JSON.stringify(state)); // Playspace keeps it across new builds, and on every device once the person signs in
}

What each call gets you

start()Someone started: a first touch, a new run, a new scene. It is recorded with each visit, and the end card closes if it is showing. Call it again on every restart.
moment(name, data)A moment in your own words, such as preset_changed, cube_added, scene_entered or chapter_opened: a snake_case name and up to 8 small fields. It is recorded with the visit for your own numbers and shown to no one. The Your works page doesn't show moments yet.
end({ score })For a work that really ends. In Playspace's player: the end card, with the score when there is one, and the leaderboard once scores are kept (the top scores on this work, and where the person ranks with their own best). Then Up next. An embed on another site shows its own end screen without the leaderboard. A work that never ends never calls it.
save(text)Up to 32,768 characters (a longer save resolves false), kept on Playspace for the person, signed in or not: in this browser until they sign in, then on every device they sign in on. Your own browser storage starts empty with every new build of your work; this does not. Read it back with playspace.load().

Good to know

  • end() freezes your work under the end card, which counts down ten seconds to Up next. Play again loads your work fresh. Call it once, where your own ending happens.
  • If your work keeps a score, send it as it changes with score(n), and the final one with end({ score }): the end card shows the last score it heard. The leaderboard ranks higher scores first.
  • A moment's name is a letter, then letters, digits and underscores, 40 at most. Each field is a number, true or false, or text up to 40 characters. The same moment counts at most four times a second, and 100 moments a visit. moment() returns true when it was sent, not that it was kept.
  • gameplayStart() and complete(), the names from before, still work and always will: they are the same calls as start() and end().
  • playspace.load() returns a promise of the saved text, or null when there is none yet (or it could not be read).

The leaderboard shows only when your work reports a score, and you can turn it off for a work in its edit sheet on Your works. Scores are your work's own: they are shown as reported, not checked (only a number beyond a trillion is refused). Equal scores share a rank.

Your works shows who came in the last 24 hours and the last 7 days: visits, people, time spent, and whether they found the work on Playspace or came from your own links.

Phones run your work too. The controls below are for when you want a phone's stick and button to drive it as your keys do.

The controls, on a computer and a phone

The whole contract in a three.js page: declare the button and your hit test once, apply the look, answer the tap and the button, and read the stick every frame. Return true for what you handled; anything else gets the player's default (a tap you leave becomes a click where it landed).

const ps = window.playspace;
let yaw = 0, pitch = 0;
ps.layout({ v: 3, action: "Jump", select: { hit: (p) => pick(p.nx, p.ny) } });
ps.camera.onLook((dYaw, dPitch) => { yaw -= dYaw; pitch = Math.max(-1.4, Math.min(1.4, pitch + dPitch)); });
ps.input.onIntent((i) => {
  if (i.type === "tap") { use(i.target); return true; } // true: handled, so no click is added
  if (i.type === "action") { if (i.on) jump(); return true; }
  return false;
});
renderer.setAnimationLoop(() => {
  const dt = Math.min(clock.getDelta(), 0.05); // a pause holds the loop: clamp the step
  const mx = ps.input.axis("moveX"), my = ps.input.axis("moveY"); // -1 to 1, up is negative
  player.position.x += (mx * Math.cos(yaw) + my * Math.sin(yaw)) * SPEED * dt;
  player.position.z += (my * Math.cos(yaw) - mx * Math.sin(yaw)) * SPEED * dt;
  camera.rotation.set(pitch, yaw, 0, "YXZ");
  renderer.render(scene, camera);
});
ps.ready();

A 2D canvas

No camera to turn, so there is no look: a drag stays your work's own. The stick is a velocity, a tap is the one act, the button jumps.

const ps = window.playspace;
ps.layout({ v: 3, action: "Jump" });
ps.input.onIntent((i) => {
  if (i.type === "tap") { shootAt(i.x, i.y); return true; } // viewport pixels
  if (i.type === "action") { if (i.on && onGround) vy = -JUMP; return true; }
  return false;
});
let last = performance.now();
requestAnimationFrame(function frame(t) {
  const dt = Math.min((t - last) / 1000, 0.05); last = t;
  x += ps.input.axis("moveX") * SPEED * dt;
  step(dt); draw(ctx);
  requestAnimationFrame(frame);
});
ps.ready();

Babylon.js

The look turns a UniversalCamera. Leave out attachControl: the drag and the keys come through the SDK on every device.

const ps = window.playspace;
const camera = new BABYLON.UniversalCamera("cam", new BABYLON.Vector3(0, 1.7, 0), scene);
ps.layout({ v: 3, select: { hit: (p) => scene.pick(p.x, p.y)?.pickedMesh ?? null } });
ps.camera.onLook((yaw, pitch) => { camera.rotation.y += yaw; camera.rotation.x -= pitch; });
ps.input.onIntent((i) => (i.type === "tap" && i.target ? (show(i.target), true) : false));
engine.runRenderLoop(() => {
  const dt = Math.min(engine.getDeltaTime() / 1000, 0.05);
  const ahead = camera.getDirection(BABYLON.Axis.Z), side = camera.getDirection(BABYLON.Axis.X);
  const mx = ps.input.axis("moveX"), my = ps.input.axis("moveY");
  camera.position = camera.position.add(ahead.scale(-my * SPEED * dt)).add(side.scale(mx * SPEED * dt));
  scene.render();
});
ps.ready();

Moving in the camera's frame

Up on the stick is ahead of the camera and right is the camera's right, both flat on the floor. Take those two directions from your camera each frame and add the stick along them. With only a turn angle a (three.js's rotation.y), it is the quick start's two lines: x grows by mx cos a + my sin a, z by my cos a - mx sin a.

const ps = window.playspace;
const ahead = new THREE.Vector3(), right = new THREE.Vector3(), up = new THREE.Vector3(0, 1, 0);
function walk(dt) {
  camera.getWorldDirection(ahead); ahead.y = 0; ahead.normalize(); // where the camera faces, flat
  right.crossVectors(ahead, up); // the camera's right
  const mx = ps.input.axis("moveX"), my = ps.input.axis("moveY"); // up is negative
  player.position.addScaledVector(right, mx * SPEED * dt).addScaledVector(ahead, -my * SPEED * dt);
}

A page with no canvas

Plain elements work the same way: the stick moves an element, a tap carries the element it landed on (select with targets), the button jumps. With no canvas, nx and ny are of the viewport. Your own buttons and links take their touches as on any page, and a tap you leave is the click where it landed. A page that reads its own touches, dragging cards or drawing, declares { v: 3, own: true } instead: nothing is raised, the stick and the button rest faded, and every first finger is yours.

const ps = window.playspace;
const me = document.getElementById("me");
let x = 40, y = 40, last = performance.now();
ps.layout({ v: 3, action: "Jump", select: { targets: [".coin"] } });
ps.input.onIntent((i) => {
  if (i.type === "tap" && i.target) { collect(i.target); return true; } // the .coin under the finger
  if (i.type === "action") { if (i.on) jump(); return true; }
  return false; // any other tap is the click where it landed
});
requestAnimationFrame(function frame(t) {
  const dt = Math.min((t - last) / 1000, 0.05); last = t;
  x += ps.input.axis("moveX") * SPEED * dt;
  y += ps.input.axis("moveY") * SPEED * dt; // up is negative, as on the screen
  me.style.transform = `translate(${x}px, ${y}px)`;
  requestAnimationFrame(frame);
});
ps.ready();

Each verb on each device

On a phoneOn a computerYour code
MoveThe stick under the left thumb, in the lower leftW, A, S and D, or the arrowsplayspace.input.axis("moveX") and ("moveY"), read every frame
LookA drag that starts on empty spaceA mouse drag that starts on empty space; or, where your work asks for it, the mouse captured after a click (Esc gives it back; your work hears pointerlockchange and decides)playspace.camera.onLook((yaw, pitch) => ...), in radians, right and up positive
TapA tapA clickAn intent { type: "tap", x, y, nx, ny, target }
The buttonThe round button in the lower rightSpaceAn intent { type: "action", on }, on as it goes down and off as it lifts; held for a moment, { type: "actionHold", on }
The second buttonThe disc up and toward the edge from the round button, under the right thumbShift or the right mouse button, or the key you declareAn intent { type: "secondary", on }, on as it goes down and off as it lifts; held for a moment, { type: "secondaryHold", on }
  • Reading the stick is what makes it live: a stick nothing reads rests faded and leaves its corner's touches to your work; a button nothing answers rests faded and is empty space (a drag there looks, a tap there taps). On a computer, reading the stick or answering a tap or a look is all it takes; nothing else needs declaring there.
  • The stick is the only way to move. A tap acts on what it lands on (use, pick, fire, open) and never walks there, so build no walk to a tap. Move in your camera's frame: up on the stick is ahead of the camera.
  • The second button is there only when you declare it (secondary: "Run"). Use it for the verb you hold: run, boost, aim; or your second action if you hold nothing. A third action rides on a hold of the button, a double tap or the dash.
  • On a computer every work is played with the same keys: W, A, S and D or the arrows, Space, Shift, the mouse and Esc. Where your manifest puts your own key on a control, the player presses it for those keys: Space presses your A's key, either Shift your B's, Esc your menu key, and W, A, S, D and the arrows your move keys (Space presses E where your A is E). A key of yours that is already Space, Shift or Esc stays exactly as it is. The arrows always move, whatever your code used them for; every other key yours reads keeps working, and Space, Shift or Esc where your code reads it for something else stays yours. With no controls in your playspace.json nothing is pressed for anyone. Nothing is pressed for a person typing in your fields or with Ctrl, Alt or Cmd held, and a focused button of yours keeps Space. Put what is held (run, boost) on B and what is tapped (jump, fire) on A: five Shift presses in a row open Windows' Sticky Keys. If your code compares event.key to a lower-case letter, it stops moving while Shift is held: compare event.code. With the mouse captured or in full screen the browser keeps the first Esc for itself.
  • On a computer your work still gets its real keys, mouse and click, and the SDK adds no second click. Keys you declare are read beside W, A, S and D, the arrows, Space, Shift and the right mouse button, never instead of them. A gamepad comes later; A and B land on the two buttons.
  • The feel of the look and the stick (its speed, smoothing and inverted look) is the player's, one setting for every work: read it with playspace.camera.comfort(), and never set it.
  • The finger's other gestures are yours to read too: a hold (on after a quarter of a second still, off at the lift), a double tap, a drag in pixels from where it started (ask for it with drag: true), a quick swipe, a finger's landing and lift as a press, a double tap that drags as a one-finger zoom, a two-finger pinch as the same zoom, and a push past the stick's edge as a dash. Every one says when the finger went down (t0), so a charge or a rhythm can run from that moment.

The declaration

playspace.layout({ v: 3, ... }) once, with only what the player cannot guess. Every field is optional; { v: 3 } alone is the plain layout.

actionThe button's word, for example "Jump", drawn in it where it is 8 letters or fewer (else the key's name). It lights the button; without it (or keys.action) the button rests faded.
secondaryThe second button's word, for example "Run". It draws the second disc beside the button with that word in it, lit while you answer it (or with keys.secondary), and lets Shift and the right mouse button press it on a computer. Without it there is no second button.
select: { hit, targets }Your own hit test at the tap's point (a raycaster takes p.nx and p.ny), or the selectors of your page's hotspots. A tap that lands on something carries it as target. None by default.
avoidThe rectangles (fractions of the screen) or selectors of your own interface: the layer never takes a touch that starts there, and the stick keeps off them. None by default.
keysThe keys the stick, the buttons, the double tap and the dash press, for code that reads keys (forward, back, left, right, action, secondary, doubleTap, dash). By default the keys the check found your build answers; the second button, a double tap and a dash press none unless you name them. On a computer the ones you name are read beside the usual keys.
forward: "always"A runner or a racer: forward is held for you, the stick steers and pulls back to brake. "toggle" turns it on and off with a tap.
scroll: trueA story read by scrolling: the page scrolls as any page does, and it ends by itself once its bottom has been on screen for a second and a half.
inspect: { distance, limits }A thing to turn in the hand: a drag turns it, a double tap steps between the two distances.
own: trueYour work reads its own touch, a sling or a pen: the stick and the button rest faded and every first finger is yours.
drag, holdDrag, doubleTap, dashdrag: true raises drags in pixels; holdDrag: "drag" picks a thing up with a hold and carries it; doubleTap: false keeps a fast second tap a tap; dash: false turns the dash off. select: { waitForDoubleTap: true } holds a tap on a target until a double tap is ruled out.

The player's signals

The player runs one work at a time. It starts your work as soon as it can be played and offers the next work when yours ends. These calls tell it what is happening. Each is optional: without them it goes by your work's first frame, by touches and by errors in the page. Calls made before the player is ready wait and go out once it is.

playspace.ready()Your work can be played. The loading screen goes and your work starts, muted until the first touch. Without it, your work's first frame does the same.
playspace.start()Someone started: a first touch, a new run, a new scene. The end card, if it is showing, hides. (gameplayStart() is the same call.)
playspace.moment(name, data)A moment in your own words, recorded for you and shown to no one: a snake_case name and up to 8 fields of numbers, true or false, or short text.
playspace.end({ score })For a work that really ends, with its score when there is one. The end card says Finished and counts down ten seconds to the next work; the person can go again or stay. (complete() is the same call. stop() ends it too, with no score: it is not a pause.)
playspace.score(n)The score now, a finite number, for a work that keeps one.
playspace.idle()Nothing is happening, for example a menu waiting for a tap. The player records it with the visit and shows nothing: there is no Still there? card, and the player never ends your work for sitting still.
playspace.progress(step, of, label)Where the person is, for example 3 of 7 with the chapter's name: whole numbers up to 999, the label up to 40 characters and optional. Sent when it changes, after your work is ready. The player records it (it is drawn nowhere), and the person's history on their phone keeps the last one.
playspace.error(message)Your work failed and cannot go on. The player says This work hit a problem., with Try again and the next work. The message, up to 300 characters, is kept for review and never shown.
playspace.on("pause" | "resume" | "mute" | "orientation" | "insets" | "facts" | "arm", fn)The player paused or resumed, muted or unmuted, the screen turned, the safe area changed, the check's facts arrived, or the person took control.
playspace.jsonA file at your work's root (a source's public/playspace.json), read when you publish. Five fields are read, each optional. "controls": false turns the on-screen buttons off; "controls" can instead hold the control manifest, the keys your work reads mapped to the buttons on a phone and to the same keys on every work on a computer (the cookbook's section 0.5). "idle" (seconds, from 30 to 600, or false) is read and kept, and changes nothing on screen: the player has no idle card. "objective" is your work's aim in one line, up to 160 characters, kept for the player's menu. "score" is { "better": "higher" } or { "better": "lower" }, with an optional "unit" ("ms" shows a time in seconds): with "lower", a person's best is their lowest and the scores board leaves your work out. "card" is what the review page fills in for you (a sentence, what it needs, the engine, the credits, the licence). A field outside its shape is ignored, and so is any field not listed here; /sdk/playspace.schema.json has every field's exact shape. Example: { "score": { "better": "higher" } }

What the player does to your page

The player is the same around every work. While yours runs, the one thing of the player's on the screen is the Playspace button, our mark in a small disc at the top left; everything else is yours. A press on it freezes your work underneath, silent and dimmed, like a console's Home button: a play disc to go back in, Leave, and beside your work the same column as always (Save, Share, More, Next and Previous). More holds Sound, Look speed and Invert look where your work looks, About with How it plays, Not for me and Report; it is the same on every work and shows nothing of yours. Sound is the player's mute, and the phone's own buttons are the volume. When your work really ends (end()) or reports an error, the end card says why, offers Share and Up next, and counts down to the next work unless the person stays.

Your work tells the player what is happening (the signals above) and hears pause, resume and mute. end, score and the outcome feed the end card and the scores board. playspace.menu, playspace.stat and progress are accepted and recorded, and drawn nowhere: your menus, pause, restart, stats and settings are yours, inside your work's frame (menu's score and restart are still read by the end card's Play again and the board). It never asks the player for anything. There is no call to hide or move the Playspace button, to add a button of your own to the Home screen or the end card, or to have the player draw a count or a colour for you, and the player still freezes your work around your own menus.

The picture's quality is the player's too: More's Quality, Auto, Low or High, the same on every work. On Auto, in the app and on a touch screen window.devicePixelRatio reads at most 1.5. Low reads 1.0, High the screen's own ratio. Every frame is yours on every tier (since runtime 1.28.0 no tier thins frames). A change reaches you as one resize just before your next requestAnimationFrame frame (a loop on timers alone gets none), never a reload; playspace.quality and playspace.on("quality") say which (SDK 0.18.0), so your own detail levels can follow. Size your drawing buffer from devicePixelRatio in your resize handler and step your loop by the time between frames. A "pixelRatio" in playspace.json, to say what your work can take, is planned and not read yet.

  • Your work runs in a sandboxed frame at its own address. Forms are never submitted: sign or send on the button's click and on the keydown of the return key instead. New windows and links that open a tab do nothing, and your page cannot move the page around it. Peer-to-peer connections are blocked and threads with shared memory are off; web workers and WebAssembly work. Full screen works only where the page around the player allows it.
  • Pause: the Playspace button, or the app going to the background, holds your page's requestAnimationFrame and timers until it resumes, so your clock jumps on resume: clamp the step your loop takes. playspace.on("pause") and ("resume") say when.
  • Sound: your work is muted until the first touch inside it. Your AudioContext's resume() resolves at once and the sound starts with that touch, so you need no tap-to-start screen. The mute suspends it; playspace.on("mute") says when.
  • The layer: on a touch screen the SDK lays a clear layer over your page with the stick, the button and the playfield, the rest of the screen. A touch on the playfield comes to you as intents, and a tap you do not handle arrives as a click where it landed. A touch that starts on your own buttons, links, fields, scrolling lists or avoid areas passes through to them as on any page. One thumb on the stick, one on the button and one finger elsewhere, never more, and the page never zooms (a two-finger pinch on the playfield is a zoom for you to read).
  • Typing: a key typed into your own field (an input, a text area, an editable element) never moves the stick or presses the button; the field gets it as on any page. On an iPhone, focus a field only from a touch, never from a timer: the keyboard rises only for a field focused by a touch, and a tapped field is focused for you. While the keyboard is up on a phone your page is the area above it (keep the field where it can scroll into view), and the player's own buttons step aside, leaving only the Home button.
  • Focus: taking control focuses your page. Every key is yours, Esc included (runtime 1.27.0): the player takes no key, and the Playspace button is a click or a tap. A browser's own Esc still lets a captured mouse go; your page hears pointerlockchange.

What the player keeps for itself, so your work never relies on it:

  1. The top-left corner holds the Playspace button, 44 by 44 pixels inside the screen's safe area, and the SDK keeps 72 by 60 pixels there clear of your controls. A touch on the button is the player's and never reaches your work, a drag included.
  2. In the app your work plays sideways, full screen, inside the screen's safe area, so its own edges have no inset (750 by 382 pixels on an iPhone 17). A swipe from the top or the bottom edge first shows the system's handle and needs a second swipe, so one swipe never leaves your work. The left edge is your work's. Size your work from the live viewport, never a phone's screen size.
  3. The top-right corner: nothing of the player's is drawn there, so your work gets those touches. The SDK's layer still keeps its own controls out of both top corners.
  4. The top of the screen is not the player's. The SDK's playfield leaves out only a band as tall as the corners, 60 pixels below the safe area, and reaches the left edge of the screen in the app.
  5. No key: Esc reaches your page like any other key (runtime 1.27.0). The Playspace button is a click or a tap.

playspace.touch.geometry() gives the screen's insets, the safe area, the player's corners and the playfield, so your own controls can keep clear of them.

Screens, pause, access and browsers

Sharp screens

In the app and on a phone or tablet's touch screen window.devicePixelRatio reads at most 1.5, even on a screen with three device pixels to each CSS pixel; on a computer it is the screen's own. The cap is set before your scripts run, and a value your code assigns is capped the same way. Only what you size from devicePixelRatio follows it: your page's text, CSS and images are drawn at the screen's full sharpness.

The person's Quality (More's Auto, Low, High) moves it while your work runs: Low reads 1.0 on every device, High the screen's own, and one resize reaches you just before your next requestAnimationFrame frame. A buffer sized once at boot follows only at the next load, and a matchMedia resolution query still answers the screen's ratio. Size your drawing buffer from it, at the start and on each resize: a canvas's width is its CSS width times devicePixelRatio, and in three.js renderer.setPixelRatio(window.devicePixelRatio). Never assume a number. A lower cap of your own is fine, for example Math.min(window.devicePixelRatio, 1.25) for a heavy scene.

Pause and the background

The player pauses your work while its tab or the app is in the background and, on the web, while the frame is scrolled out of view. It also freezes when the person presses the Playspace button and while a sheet or the end card covers it, and a work left in the background comes back frozen, under the Home screen, until the person goes back in. playspace.on("pause") and ("resume") say when.

While paused, your requestAnimationFrame callbacks wait and run at the first frame after resume, a setTimeout that falls due runs just after resume, and the ticks of a setInterval are skipped, not made up. The clock does not stop: performance.now() and the frame's timestamp jump by the length of the pause, so clamp the step your loop takes. Not held: CSS animations and transitions, video, web workers, MessageChannel loops and promises.

Pause holds your sound as well: it suspends every AudioContext and pauses every audio and video element, and resume starts them again unless the player has the sound muted. Sound, the player's mute, does the same until it is unmuted. A tab that goes to the background pauses your work too, and your pause and resume handlers hear it once each.

On pause the SDK lets go of every finger: the stick reads 0, the button sends its off, and a held forward is let go; its layer is hidden until resume. When the page loses focus (the person switches window or tab), the keys the SDK reads are let go, so the stick reads 0, and a held Space sends the button's off. Clear your own key table on blur too: the key-up of a key held as focus left never arrives.

Accessibility

What the player gives: the frame is titled with your work's title for a screen reader, and the Playspace button is labelled. The SDK's layer, the stick and the button, is hidden from screen readers and draws no words; when the system asks for reduced motion, its fades are off. On a computer the keys are W, A, S and D or the arrows, read by their position on the keyboard so any layout works, Space, and Shift or the right mouse button for the second button, each pressing your own key where your manifest names one; there is no other remapping. The stick, the look and the buttons are made for sight and touch, and the player has no other way to move or look.

What is yours is everything inside your frame. Keep words as text in your page where you can (a screen reader cannot read words drawn on a canvas), label your own buttons, follow prefers-reduced-motion for shakes, flashes and a swaying camera, never carry meaning by colour alone, and show on screen what a sound tells.

Browsers

The script Playspace adds and the SDK are plain ES2017 and add no polyfills; the layer reads Pointer Events. Your page needs only what your own code needs.

In the app your work runs in the iPhone's own WebKit; on a computer and in embeds, in the person's browser. Every build's check runs in Chromium 153, as a phone and as a computer, drawing with WebGL 2 in software and with no WebGPU, so a page that needs WebGPU and has no WebGL fallback may not pass it. Our own tests also run the player's frame in WebKit 26.6. Firefox is not tested.

Saves, servers and multiplayer

playspace.save keeps a player's progress on Playspace, signed in or not: a new build of your work keeps it, a player who isn't signed in keeps it in this browser, and signing in carries it to every device they sign in on. The work's own browser storage belongs to one build, so a new build starts it empty. On a computer, an embed on another site plays your work right there in that site's page. Inside it, your work's own saves stay on that website, and saves through playspace.save follow the player on Playspace only. Wrap storage calls in a try/catch: some browsers refuse storage inside embeds. On a phone, Play opens the work on Playspace in a new tab. Your own server is reachable only if you allow its host at review (the check lists the hosts your build tried during its run): over https:// on the standard port, and over wss:// for web sockets, which we have not yet proven with a test build. Peer-to-peer connections (WebRTC) are blocked, and Playspace has no built-in multiplayer.

Testing

Testing locally: run pnpm sdk:try ./my-work (your folder, or the .zip you would upload) and open the localhost address it prints. Your page runs on your own computer with the real script and SDK, framed as the player frames it, as a phone (750 by 382 pixels, touch emulated, your mouse as one finger) or as a computer, beside a panel that shows live what the SDK reads: the reading, whether the stick and the action button are live, whether something reads movement, whether there is a view, and each intent as it arrives. Its four buttons test the four verbs (hold the stick, drag, tap, press the button) and say pass, fail, or not here and why. Nothing is uploaded; then publish it and play it on a phone and a computer.

Outside Playspace window.playspace is not there, so guard your calls (const ps = window.playspace; if (ps) ...) and keep your own controls for that case. Inside, playspace.touch.geometry() tells you what the SDK thinks: sticks.move.live and action.live for the stick and the button, move for whether something reads movement, view for whether a drag turns a view.

You upload once, a source project or a build, as you have it. When you publish, Playspace checks your upload, then its AI reads your work and adds to it without changing how it looks or plays: the SDK (the lifecycle, and your controls as a manifest so it answers on a phone and a computer), the moments it counts for you, and a list of its files with where they came from. The result goes through the same checks, and you look it over on the review page. If the AI's additions do not pass, your upload publishes as you sent it, with Playspace's player around it: the controls on a phone, the Playspace button, the sound and the pause. Only a few things can hold your work back, the safety scan and the controls among them; everything else is measured and never stops it.

What holds publishing

  • The files: a .zip or a page, with index.html at its top or one folder down, at most 1,000 files and 100 MB unpacked, nothing that cannot run in a browser and no path that points outside the zip.
  • The safety scan: every file goes through a virus scan, and what the AI adds is scanned too: a new network call, new storage or eval in it holds the work until we take a look.
  • The controls: every work on Playspace is played with the same few controls, a stick, two buttons, a tap and a drag on the work, and a menu button on a phone; W, A, S and D or the arrows, Space, Shift, the mouse and its click, and Esc on a computer. These controls are the format. A work that needs more (a third button, a number row, or typing as the play itself) is published for now with those actions left out, and may not be accepted later. Other keys can stay when each only repeats something on your screen or play does not depend on it (a horn, a second camera, a debug key), and typing a name into a field is fine. The AI lists every way a person acts on your work, and where it finds your work needs more, a second, separate AI reading checks that.
  • The player's runtime mounts: it is added to every page, and a build that draws on its own but stops with it is held.
  • A frame is drawn on a computer within a minute, with no more than 30 MB loaded before it. Threads with shared memory and a page that needs WebGPU with no WebGL fallback stop here.
  • Also refused: a source that does not build, a file fetched from a CDN whose bytes changed, a file under /.playspace/ (the player's), and a page that stops on an error before it draws.

What is measured and never holds it

  • The controls on a phone and on a computer: which keys, clicks, taps and touches it answers, whether the stick moves it, a drag turns the view, a tap acts and the buttons answer.
  • How much it loads before its first frame and how long that takes, on a phone, and on a computer under the 30 MB above.
  • How fast it draws: the frame rate on a computer and at a phone's speed.
  • The SDK calls it makes: ready, start, end, score and the rest.
  • Whether it draws on a phone, and upright.

These shape the player around your work and what you see on the review page; none of them stops it from publishing.

Versions

playspace.sdk.version says which SDK your page has (0.28 today). The SDK comes with the page Playspace serves, so every work gets the same one.

From 0.9 the names are frozen: the four verbs (input.axis("moveX") and ("moveY"), camera.onLook, the tap through input.onIntent, and the button's action), every word of playspace.layout({ v: 3, ... }), the names and fields of the intents, and the signals (ready, gameplayStart, complete, score, progress, idle, error, on, save, load, share) keep their names and what they mean. 0.10 added start, stop, end and moment, the neutral names: start and end are gameplayStart and complete, stop is end with no score, and both sets work. 0.11 added the second button (secondary in the declaration and the intents). 0.13 added playspace.menu, playspace.stat, end's outcome and the setting, restart and mode events, so the pause screen can show what your menu held. 0.14 added the slots touch.geometry() reports (C and D beside A and B, a left column, a slot bar, a menu button) where the controls your page reads are presented from its control manifest. 0.15 added touch.geometry().orientation, landscape or portrait, since a phone plays every work in both. 0.16 draws only the controls a work uses: a stick, A or B that nothing listens to is not drawn at all, and touch.geometry() says drawn beside live. 0.17 gives a page that reads its own touch (own) every finger, so its own pinch and two-finger pan reach it, and takes a dot in a choice's option ids. 0.20 draws every work with the same few controls on a phone (a stick, A, B and a menu pill at the top left, from the control manifest's version 3) and drops touch.show, which 0.19 added and no published page ever had. Later versions only add: a new intent, a new word for the declaration, a new event, and a page that ignores what is new plays as before. The numbers behind them (how long a hold takes, the sizes, how fast a drag turns) are the player's and can be tuned. touch.geometry(), touch.controls(), reading playspace.layout() back and pnpm sdk:try are for testing, not for steering your work. The camera presets, loop and audio helpers are optional and can still change. Version 1.0 comes when the rewrite of uploaded code onto the SDK works on its test set with no change to the SDK; then each build keeps the version it was published with.

One shape: a declaration is { v: 3, ... } and nothing else. The layouts from before version 3 (v: 2 with a grammar word, and the version 1 sticks and pads) are gone and lay nothing out, so such a page plays as if it declared nothing. Gone too: the old input calls (input.use, bind, down, pressed, released, on, emitKeys), the old touch helpers (touch.insets, click, fit, state; and since 0.20 touch.show: our controls appear when your work calls start()), and the old names: touch.layout is playspace.layout, the double tap is doubleTap (it was once called secondary, a word that now names the second button), the push past the stick's edge is dash (it was thrust, with keys.sprint), and select.hold is select.waitForDoubleTap. playspace.gameplayStop() belongs to the old script below; with the SDK, say end(). The camera presets and the SDK's own walking are optional three.js conveniences, loaded only when you call them, and not the contract.

A work that ignores the SDK

Code that never calls the SDK still plays. The check learns which keys your work answers and whether it takes a pointer lock, and on a phone the layout is made from that: the stick presses the movement keys it found (W, A, S and D, the arrows, or Z, Q, S and D), a drag moves your work's mouse, a tap clicks where it lands, a hold is a held click, and the button holds Space when your work answers it. A work that answered a touch keeps its own touches. On a computer it is left as it is. That covers works made for a keyboard and a mouse.

Your upload is kept as you sent it. The build players get is your work with the AI's additions (the SDK, the moments, the list of its files), checked as above, or your upload as it is when those do not pass; you look it over on the review page before it goes live.

Legacy: the playspace.js script

An optional script, a few hundred bytes, from before the SDK. It tells the player when your work is ready, when a run starts and ends, the score, and what to save, and has none of the controls above. It only posts messages to the page around your work: it makes no network calls, and your work runs the same without it. The SDK already has every call it has.

Load it from the site, or copy the file into your zip (the check reads its version either way).

<script src="https://www.joinplayspace.com/playspace.js?v=0"></script>
playspace.ready()Your work drew its first frame and can be played. The check stops waiting early.
playspace.gameplayStart()A run started. The end card hides.
playspace.gameplayStop()A run ended. With a score, the end card shows it, with Share and Play again.
playspace.score(n)The score now: the bar shows it, and the best one goes on the result card.
playspace.save(text)Keeps up to 32,768 characters (64 KB) of text for the player: in this browser until they sign in, then on every device they sign in on. Resolves true when kept.
playspace.load()Resolves the saved text, or null when there is no save yet.
playspace.share({ title, text })Opens the share sheet with your words.
playspace.on("pause" | "resume" | "mute" | "orientation", fn)The player paused, resumed, muted, or the phone turned.

Messages go to the page around your work only, and are checked there: a message from anywhere else is dropped.

Playspace also runs a small script of its own in front of your work, added as the work is sent to the browser (your files are not changed). It keeps your work still, silent and hidden until the Playspace player around it says start, so your work plays only inside that player. Opened at its own address, your work shows a link to play it on Playspace instead.

Plain HTML

<script src="https://www.joinplayspace.com/playspace.js?v=0"></script>
<script>
  // after your game's first frame
  playspace.ready();
  function startRun() { playspace.gameplayStart(); }
  function endRun(score) { playspace.score(score); playspace.gameplayStop(); }
  playspace.load().then((saved) => { if (saved) restore(JSON.parse(saved)); });
  function checkpoint(state) { playspace.save(JSON.stringify(state)); }
</script>

Three.js

<script src="https://www.joinplayspace.com/playspace.js?v=0"></script>
<script type="module">
  import * as THREE from "./three.module.js";
  const renderer = new THREE.WebGLRenderer({ antialias: true });
  let paused = false, first = true;
  playspace.on("pause", () => (paused = true));
  playspace.on("resume", () => (paused = false));
  renderer.setAnimationLoop(() => {
    if (paused) return;
    renderer.render(scene, camera);
    if (first) { first = false; playspace.ready(); }
  });
</script>