Skip to content
klyogames

What are you adding?

One account for players and developers. Posts and clips go to the community, games to the catalogue after a check.

Game (ZIP)Your own address and stats, plus a share of the ads once we switch them on. Live after the automatic check. Clip of a gameRecord 15–30 s of gameplay with one click in the studio. Community postText, photos or a video up to 30 s: a question, a playtest request, a launch.

Your game

How to save player progress in an HTML5 game

Add the klyo SDK to index.html, call klyo.save.get when the game starts and klyo.save.set after each meaningful change. Progress is stored on the klyo server, follows a signed in player to every device, and you can test it in the studio preview before you publish.

Before you start

  • A browser game (plain JavaScript, Godot, Unity, GameMaker or any engine that exports to the web) and access to its index.html.
  • The game state as an object that fits in 64 KB, for example level, coins and settings.
  • No server or database on your side: the SDK and the klyo page do the rest.

Step by step

  1. Add the SDK

    Put this line in index.html before your own script: <script src="https://games.klyo.pl/sdk/klyo-gry-sdk.js"></script>. An engine that exports to the web calls the same functions through its own way of calling JavaScript from the game.

  2. Load progress at start

    Call klyo.save.get(callback) once when the game starts. When z.ok is true and z.data is set, restore the game from z.data. z.cloud is true when the klyo server answered, and z.reason says why the data comes only from the browser.

  3. Save after meaningful changes

    Call klyo.save.set(state, callback) after a level, a purchase or a change of settings. The SDK keeps a copy in the browser and merges saves that come faster than every 2 seconds into one, so you do not need a timer of your own.

  4. Test it in the studio preview

    Upload the package and play in the preview window. Saves go to the preview cloud that only you can see, and the answer has o.cloud and o.preview set to true. Call klyo.save.get again, or open the preview again, and the same data comes back with z.source equal to "chmura".

  5. Publish the game

    After release every player saves into a slot of their own: a signed in player keeps progress on every device, a guest keeps it in this browser. Your preview save disappears together with the preview.

If something goes wrong

The answer says the data is local

z.reason tells you why. bez-strony: the game runs outside klyo (straight from a file or on another site), so progress stays in the browser. bez-serwera: there was no connection, and the SDK sends the copy again later. pusto-w-chmurze: the cloud had nothing yet, so the game got the browser copy and the SDK sent it to the cloud.

My code waits and then gives up

The answer always arrives, at the latest after 8 seconds, and on klyo it arrives at once. Remove a shorter timeout of your own and start the game from the browser copy while the cloud answers.

A save is rejected with rozmiar

The state is larger than 64 KB once encoded. Save only what you need to restore the game, not the whole scene.

Common questions

Does the player need an account to keep progress?

No. Without an account progress belongs to this browser. With an account it follows the player to every device, and the copy saved in this browser before signing in moves to the account.

What happens when two devices save at the same time?

The latest save in the cloud wins. A browser copy that the server has not confirmed yet goes up only when no other device saved in the meantime, so an older copy never overwrites newer progress.

Do players see my test saves from the preview?

No. The preview has a slot of its own that only you and klyo moderators can open, and it is deleted together with the preview.