For game developers
The NewFans game script
Sell a web game on NewFans and give it saves that follow the fan, leaderboards, card unlocks, and a report of where players stop, with one script tag. Fans also get a "Tell the maker" button under your game, and their notes land on the game's analytics page.
1. Add the script
Put this tag in your game's index.html, before your own scripts. If you upload a zip without it, NewFans adds it to the entry index.html for you when the build is unpacked.
<script src="https://newfanspro.com/sdk/newfans-game.js"></script>The script defines window.NewFans. Every call returns a promise that resolves to { ok, status, data } and never throws. When the game runs outside a NewFans page (on your own machine, say), every call resolves at once with ok: false, so your game keeps its own local copy and carries on.
2. Saves
// Save up to 512 KB of JSON per slot (slots 0 to 9) on the fan's NewFans account.
const saved = await NewFans.save({ level: 3, coins: 120 }, 0);
if (!saved.ok) console.log('Not saved:', saved.status, saved.data.error);
// Load it back on any device the fan plays on.
const loaded = await NewFans.load(0);
if (loaded.ok && loaded.data.exists) startFrom(loaded.data.data);A save made on another device since you loaded answers status: 409 with the newer save in data, so you can choose which one to keep.
3. Leaderboards
// Post a score. The fan's best score per board is kept.
await NewFans.submitScore(4200, { board: 'main' });
// A time trial, where lower is better (the first score fixes the direction).
await NewFans.submitScore(73.4, { board: 'speedrun', lowerIsBetter: true });
// Read a board: everyone, or only the creator's paying Backstage members.
const board = await NewFans.leaderboard({ board: 'main', limit: 10 });
if (board.ok) render(board.data.entries, board.data.me);Up to 20 boards a game, one score every two seconds per fan. Names are the fan's NewFans display name. Scores are reported by the game on the player's device, so treat a board as a fan feature, not proof that a score was earned. The creator can remove a score.
4. Where players quit
// Tell NewFans where the player is. Levels count from 0.
NewFans.levelStart(2, 'Caves');
NewFans.levelComplete(2, 'Caves');
NewFans.levelFail(2, 'Caves');
NewFans.gameOver();The creator sees, for the last 30 days, how many players reached, cleared, failed and quit each level, on the drop's analytics page. No player identity is sent: each page load is a random session.
5. Card unlocks
// Keys the fan's tap cards unlock in this game, set by the creator in Tap Studio.
const keys = await NewFans.unlocks(); // e.g. ["item:gold_skin", "level:3"]
if (await NewFans.hasUnlock('level:3')) openBonusLevel();An unlock only adds something. Never make finishing the game depend on one: a fan who bought the game without a card must still be able to play all of it.
Who may save
Saves and scores work for a signed-in fan who may play the game: the creator, a fan who bought it or tapped its card, a Backstage member when the game is for members, and anyone signed in for a free game. If a purchase is refunded or disputed, saving stops with status: 403 and the code not_owned. A status: 503 means NewFans could not check just now; try again later.
A fan who is signed out can still save: the page keeps the save in their browser and moves it to their account the next time they play signed in. Scores need a signed-in fan.
A downloaded build (Windows, Mac, Android) links once. The fan taps "Get my save code" on the game's download card and types the code into your game, which sends it to POST /api/games/save-link/exchange as { "code": "..." }. The answer carries a token good for 30 days. Send it as Authorization: Bearer <token> to POST /api/games/progress with the same bodies the script sends ({ "action": "write", "slot": 0, "data": {...} }, read, score). A status: 401 means the token ran out: ask for a new code.
Built with MCPity? Your game already speaks to NewFans, so you do not need this script. Sell a game on NewFans