Skip to content

Cloud storage

FRVR.cloudStorage is a per‑player server‑side key‑value store, keyed off the authenticated FRVR ID. Use it for anything that must survive device switches: save games, unlocked content, friend invites.

await FRVR.cloudStorage.setItem('save', JSON.stringify(state));

const raw   = await FRVR.cloudStorage.getItem('save');
const state = raw ? JSON.parse(raw) : null;

await FRVR.cloudStorage.removeItem('save');

Same string‑value contract as local storage.

Minimize round trips when you have multiple keys:

await FRVR.cloudStorage.setItems([
  { key: 'save',      value: JSON.stringify(state) },
  { key: 'unlocked',  value: JSON.stringify(unlocks) },
]);

const { items } = await FRVR.cloudStorage.getItems(['save', 'unlocked']);

Data you want friends to be able to see — e.g. your best score for a leaderboard snippet, your active guild — goes through setPublicItems / queryPublicItems:

await FRVR.cloudStorage.setPublicItems([
  { key: 'best_score', value: '42000' },
]);

// From another player's device:
const result = await FRVR.cloudStorage.queryPublicItems({
  userIds: ['friend_frvr_id_1', 'friend_frvr_id_2'],
  keys:    ['best_score'],
});
FRVR.config.cloudStorage = {
  playerStorage: { env: 'production' },   // or 'staging'
};

The SDK falls back to in‑memory storage if cloud init fails — so your game keeps running, but the data won’t sync. Always check for a falsy read before treating a missing value as “user has no save”.

Cloud storage: roundtrip

loading SDK…