What cloud saves do
Cloud saves store a JSON progress object for one signed-in player and one registered game. The same Vihar ID can retrieve it on another device after signing in to that game. Direct-play activity tokens cannot read or write saves.
The studio decides what to save and when. Vihar does not inspect the engine to infer checkpoints, inventory or levels, and it does not turn an existing offline save into a cloud save automatically. Never store passwords, payment data, health information or arbitrary personal documents in game progress.
Load first, then save a checkpoint
restoreGame, currentLevel and currentCheckpoint are placeholders for your engine. Keep the save format versioned and validate loaded values before applying them. Save at meaningful checkpoints, not every animation frame. The JSON object limit is 60 KB and the per-player, per-game save endpoint allows 60 requests per minute, including reads.
let revision = 0;
const saved = await vihar.loadProgress();
revision = saved.revision;
if (saved.data) restoreGame(saved.data);
async function saveCheckpoint() {
const result = await vihar.saveProgress({
schemaVersion: 1,
level: currentLevel,
checkpoint: currentCheckpoint
}, revision);
revision = result.revision;
}Handle two devices without silent overwrites
- Read the saved object and revision after sign-in.
- Send that revision with every save. Update your local revision only after success.
- If the API returns save_conflict (409), another writer changed the save. Keep the player's local state and load the latest server save.
- Let the player choose or merge compatible progress deliberately. Never retry a stale write by guessing a newer revision.
Progress is not trusted competitive scoring
Browser players can modify the data their game sends. Treat cloud saves as player-controlled progress, not authoritative scores, purchased currency, entitlements or leaderboard proof. Validate competitive and paid state in your own trusted backend.
Disconnecting a game revokes access but retains progress. Signing out clears the SDK's token, not the save. Account data export includes stored saves; contact support for deletion requests. Only claim cross-device saves in your listing once your own load/save flow has been tested.