Example: Hello Spawnle
Hello Spawnle is a tap game in a single index.html. It shows:
- the signed-in player, with their studio badge,
- a cloud save of the score,
- three achievements (
first-tap,ten-tapsand the hiddenfifty-taps), - a leaderboard (
taps), - rich presence (“Points: 12”).
Play it in your browser (local mode) or
download the source — one HTML file
plus spawnle.js. The important
parts:
const spawnle = await Spawnle.init({ localPlayer: { name: "Local player" } });
// Who is playingnameLabel.textContent = spawnle.user.displayName;modeLabel.textContent = spawnle.mode === "spawnle" ? "Connected to Spawnle" : "Local mode";
// Pick up where they left offconst saved = await spawnle.saves.load("progress");let score = saved ? JSON.parse(saved).score : 0;await spawnle.presence.set(`Points: ${score}`);
button.onclick = async () => { score++; const key = { 1: "first-tap", 10: "ten-taps", 50: "fifty-taps" }[score]; if (key) { const result = await spawnle.achievements.unlock(key); if (result.newly) toast(`🏆 ${result.name}`); } if (score % 5 === 0) spawnle.presence.set(`Points: ${score}`);};
saveButton.onclick = () => spawnle.saves.save("progress", JSON.stringify({ score }));
submitButton.onclick = async () => { const { improved, rank, best } = await spawnle.leaderboards.submit("taps", score); status.textContent = improved ? `New record! #${rank}` : `Your record is still ${best}.`; const board = await spawnle.leaderboards.get("taps", { limit: 5 }); render(board.entries);};Try it
Section titled “Try it”- Put
index.htmlandspawnle.jsin a folder and openindex.html: it runs in local mode. - Publish it (zip the folder) with the visibility Only me.
- In its SDK page, add the three achievements and the
tapsleaderboard, then play it from the launcher.