Skip to content

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-taps and the hidden fifty-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 playing
nameLabel.textContent = spawnle.user.displayName;
modeLabel.textContent = spawnle.mode === "spawnle" ? "Connected to Spawnle" : "Local mode";
// Pick up where they left off
const 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);
};
  1. Put index.html and spawnle.js in a folder and open index.html: it runs in local mode.
  2. Publish it (zip the folder) with the visibility Only me.
  3. In its SDK page, add the three achievements and the taps leaderboard, then play it from the launcher.