For creators

Cloud saves

Let players keep their progress. When your game runs on FreshSpawn, it can save to the player's FreshSpawn account, so their levels, coins and unlocks are still there next time — even on a different device.

How it works for players

  • Signed in: progress is saved to their account and follows them anywhere.
  • Not signed in: progress is kept on that device, and FreshSpawn reminds them to sign in. The moment they sign in, it moves into their account so nothing is lost.
  • Playing never needs an account. Saving to the cloud is a bonus.

1. Paste this into your game

Works with any web game: plain JavaScript, Scratch exports with custom JS, Phaser, Construct, Godot web and more.

// FreshSpawn cloud saves — paste this into your game's JavaScript.
const FreshSpawn = (() => {
  const waiting = {};
  window.addEventListener("message", (e) => {
    const m = e.data;
    if (m && m.type === "freshspawn:result" && waiting[m.requestId]) {
      waiting[m.requestId](m);
      delete waiting[m.requestId];
    }
  });
  function ask(type, extra) {
    return new Promise((resolve) => {
      // Not on FreshSpawn? Answer "not available" so your game keeps working.
      if (window.parent === window) return resolve({ ok: false, error: "Not on FreshSpawn" });
      const requestId = Math.random().toString(36).slice(2);
      waiting[requestId] = resolve;
      window.parent.postMessage({ type, requestId, ...extra }, "*");
      setTimeout(() => { if (waiting[requestId]) { delete waiting[requestId]; resolve({ ok: false, error: "No answer" }); } }, 5000);
    });
  }
  return {
    save: (data, slot = "default") => ask("freshspawn:save", { data, slot }),
    load: (slot = "default") => ask("freshspawn:load", { slot }).then((r) => (r.ok ? r.data : null)),
    remove: (slot = "default") => ask("freshspawn:delete", { slot }),
  };
})();

2. Load when the game starts, save when they make progress

// When the game starts:
const saved = await FreshSpawn.load();
if (saved) { level = saved.level; coins = saved.coins; }

// Whenever the player makes progress:
FreshSpawn.save({ level, coins });

Good to know

  • Save plain data: numbers, text, true/false, lists and objects.
  • Each save can be up to 100 KB — plenty for progress, not for big files.
  • Want several save files? Pass a slot name, like FreshSpawn.save(data, "slot2"). Up to 10 slots per player per game.
  • Only your game can read its own saves. Players' saves are private to them.
  • Cloud saves only work when your game is played inside FreshSpawn, not when opened in a new tab.