creator platform
A small browser SDK gives static games authenticated platform features without exposing player sessions or API keys.
Add capabilities to slopfarm.json. Browser uploads can select the same options in the upload form.
"capabilities": {
"saves": true,
"multiplayer": { "maxPlayers": 4 }
}Add this script to the game's HTML. This is the only approved external runtime dependency. It contains no secret and talks only to the Slop Farm parent player.
<script src="https://slopfarm.games/sdk/slopfarm.js"></script>Call await SlopFarm.ready() before showing platform controls. Signed-out saves stay in protected local storage on the Slop Farm parent; multiplayer requires a signed-in player.
const save = await SlopFarm.saves.load("main");
const state = save?.state ?? { level: 1, coins: 0 };
const updated = await SlopFarm.saves.save("main", state, {
schemaVersion: 1,
expectedVersion: save?.version ?? 0
});Each game gets five named slots, each up to 64 KB of JSON. Saves follow the stable game across releases. Use expectedVersion to detect another tab or device changing the same slot.
// Host
const room = await SlopFarm.multiplayer.create({ maxPlayers: 4 });
showInviteCode(room.code);
// Guest
await SlopFarm.multiplayer.join(codeFromPlayer);
SlopFarm.multiplayer.onMessage(({ event, data, sender }) => {
if (event === "move") applyRemoteMove(sender.userId, data);
});
await SlopFarm.multiplayer.send("move", { x, y, frame });Rooms support 2–8 signed-in players, private six-character invite codes, presence, reconnect heartbeats, host migration, and release locking. Messages are JSON, at most 4 KB, and capped at 30 per second per player.
The room host or your game clients decide the game state. Treat incoming messages as untrusted, clamp every value, include sequence numbers, and periodically send a complete snapshot. This SDK is suitable for co-op, party, board, racing, and casual action games; it is not a cheat-proof ranked server.
Do not build free-text chat unless you also build mute, block, report, and moderation controls. Prefer emotes and bounded game actions.
onPresence reports currently connected room members.onRoom reports membership or host changes.onError reports heartbeat and connection failures.SlopFarm.multiplayer.leave() when returning to a title screen.Type declarations are available at /sdk/slopfarm.d.ts.