Skip to content

Quick start

This guide uses a web game. Native games work the same way through the REST API.

  1. Add the SDK to your game.

    Download spawnle.js (or install it from npm), ship it with your game and load it:

    index.html
    <script src="spawnle.js"></script>
    <script type="module" src="game.js"></script>

    The launcher also serves the SDK next to your game at /__spawnle/sdk.js, always matching the launcher’s version; use that path if you prefer, but it only exists inside Spawnle.

  2. Start a session.

    game.js
    const spawnle = await Spawnle.init();
    console.log(`Hi ${spawnle.user.displayName}!`); // already signed in
    console.log(spawnle.mode); // "spawnle" or "local"

    Opened outside Spawnle, init() runs in local mode: a stand-in player and everything kept in localStorage, so your game keeps working while you build it.

  3. Save the player’s progress to the cloud.

    await spawnle.saves.save("slot1", JSON.stringify({ level: 3, coins: 120 }));
    const saved = await spawnle.saves.load("slot1"); // null when empty
    const state = saved ? JSON.parse(saved) : newGame();
  4. Define an achievement and unlock it.

    In the launcher, open Developer dashboard → your game → SDK, add an achievement with the key first-win and save. Then, in your game:

    const result = await spawnle.achievements.unlock("first-win");
    if (result.newly) showToast(`🏆 ${result.name}`);

    Unlocking twice is harmless: newly tells you whether it was new.

  5. Try it in the launcher.

    Publish your game with the visibility Only me to test it privately, then press Play from your library. Inside Spawnle, spawnle.mode is "spawnle" and saves, achievements and scores reach the cloud.

Terminal window
npm install @spawnle/sdk
import Spawnle from "@spawnle/sdk";
const spawnle = await Spawnle.init();

The package ships TypeScript types.