Docs menu Cloud save
Cloud save
Last updated 2026-11-21
Two calls keep a player’s progress: save.set() and save.get(). For a player who is signed in to FreeGames.gg with a Foony account, saves are kept on that account, so the progress is there on their phone, their laptop and any other browser. A guest’s saves stay in their browser, and they move to the account when the guest signs in.
Save and load
const SAVE_KEY = 'progress';
async function loadProgress() {
const text = await sdk.save.get(SAVE_KEY);
return text ? JSON.parse(text) : {v: 1, level: 1, coins: 0};
}
async function saveProgress(progress) {
const isSaved = await sdk.save.set(SAVE_KEY, JSON.stringify(progress));
if (!isSaved) {
console.warn('Progress was not saved this time.');
}
}- Values are text. Use
JSON.stringify()andJSON.parse()for objects. save.get()resolvesnullwhen there is no save.save.set()resolvestruewhen the save was kept, andfalsewhen it wasn’t. Neither call ever rejects.- Call
save.get()once while your game loads, afterinit(), and keep the result in memory.
Who keeps the saves
| Player | Where saves are kept |
|---|---|
| Signed in with a Foony account | On the account. The page reads all of the game’s saves once per visit, so later save.get() calls answer at once. |
| Guest | In the browser’s storage for FreeGames.gg. A player who clears their browser data starts again. |
| No page around the game | Nowhere: save.get() resolves null and save.set() resolves false. |
Saves are private. Your game reads only its own player’s saves for your game. No other game, and no other player, can read them.
When a guest signs in
The first time a signed-in player opens your game, the page sends the saves this browser kept for your game as a guest:
- If the account has no saves for your game yet, the guest’s saves move to the account, and the browser copy is deleted. The player keeps playing where they were.
- If the account already has saves for your game (the player played before on another device), the account’s saves stay, and the guest’s saves stay in the browser. Nothing is mixed key by key, because half of one run and half of another can break a game.
Your code does nothing for this. Read your save with save.get() after init(), and the right one comes back.
Limits
| Limit | Value |
|---|---|
| Key | 1 to 64 characters |
| All saves of one game for one player | 1,000,000 characters, all keys and values together (about 1 MB of plain text) |
| Keys of one game for one player | 1,000 |
| Writes | One a second per game. See below. |
Characters are counted the way JavaScript counts text.length, so an emoji counts 2. A save.set() over a limit resolves false and keeps the old saves.
If your game needs more, tell us in your game’s messages.
How often to save
The page sends at most one write a second for your game. If you call save.set() faster, the page sends the newest value of each key and skips the ones in between. Each save.set() resolves when the write that holds its value is done.
- Save at checkpoints: a level end, a purchase in your shop, a settings change. Not every frame.
- Save when the progress happens, not on a timer and not when the tab closes. Your game can’t send anything once its page is closing, so a game that saves every 3 minutes loses up to 3 minutes when the player reloads. An idle game can save each time a number the player cares about changes, at most once a second.
- Keep one key for the main progress and a few for settings.
- Put a version number in your save (
{v: 2, level: 4}), so a new build can read an old save. - If a write is still waiting when the player closes the tab, the page sends it as the tab closes, when the value is under 60 KB.
The inspector shows every save your game makes, and warns when you save too often, a value is too big, or a value isn’t text.
When saving fails
- If the page can’t read a signed-in player’s saves (no network, or our servers are down),
save.get()resolvesnullandsave.set()resolvesfalsefor that visit. Start a fresh run but keep it in memory, and don’t tell the player their old progress is gone. - In a private window, or where the browser blocks storage, a guest’s
save.set()resolvesfalse. Keep the game playable: hold progress in memory for the visit.
Coming from CrazyGames or Poki
CrazyGames’ data.setItem() and data.getItem() work here too (see Coming from CrazyGames). data.setItem() also sends each value to save.set(), but data.getItem() reads only the browser’s copy, so a signed-in player on a new device starts again. Use save.get() when you want saves on every device. Poki has no save module. Use save.set() and save.get(), or keep your localStorage code inside try.