Skip to content

Local storage (Cocos)

Persistent on the device the game is running on. Ideal for preferences, caches, and anything that’s cheap to regenerate if lost.

All methods are on the FRVRSDK.instance singleton and return Promises.

await FRVRSDK.instance.localStorageSetItem('coins', 100);
const coins = await FRVRSDK.instance.localStorageGetItem('coins');   // → 100 | null
await FRVRSDK.instance.localStorageRemoveItem('coins');

Values can be any JSON‑serializable value — the wrapper handles serialization for you (unlike the raw Web SDK, which deals in strings).

Batch APIs save roundtrips when you have multiple keys. Use them in save/load points.

await FRVRSDK.instance.localStorageSetItems([
  { key: 'score',        value: 4200 },
  { key: 'level',        value: 5 },
  { key: 'tutorial_done', value: true },
]);

const items = await FRVRSDK.instance.localStorageGetItems(['score', 'level', 'tutorial_done']);
// items is an object keyed by your input keys

await FRVRSDK.instance.localStorageRemoveItems(['legacy_key', 'temp_run']);
Use local storage when…Use cloud storage when…
Data is cheap to regenerateLosing it would ruin the player’s progress
It’s device‑specific (audio mute, graphics preset)It should follow the player across devices
You don’t need the player to be logged inThe player has a FRVR auth session

Game saves, unlocks, and IAP‑granted content belong in cloud storage. Preferences and caches belong in local storage.