Skip to content

Data Module

This page explains how to use the Playol SDK’s data module to store and synchronize game data across devices — without any backend setup. It supports reading and writing structured data like save progress, configuration, and achievement status.

The data module provides a platform-hosted sync mechanism that allows developers to persist player progress, settings, and other structured data tied to their identity. All data is bound to the current user account and can sync across devices automatically.


📌 1. Use Cases

  • Store level progress, settings, temporary game states, event triggers, etc.;
  • No backend database needed — all data is hosted by the platform;
  • Players can resume progress on any device after login (cloud save);
  • All data is bound to userId and accessible only in login state;
  • Supports structured values with a per-user limit of 1MB;
  • All method calls are made synchronously.

🧩 2. Methods & Usage

📥 Get Data

get(k)

Retrieve the value for a specific key.

js
const level = window.playolSDK.data.get('currentLevel')
console.log(level)

getAll()

Retrieve all stored data for the current user as a key-value object.

js
const allData = window.playolSDK.data.getAll()
console.log(allData)

📤 Set Data

set(k, v)

Save a value for a specific key. Supports various data types and syncs automatically.

ParameterTypeRequiredDescription
kstringKey name
vstring | number | boolean | objectAny valid value
js
window.playolSDK.data.set('musicOn', true)
window.playolSDK.data.set('currentLevel', 12)
window.playolSDK.data.set('config', { speed: 3, volume: 0.8 })

📌 Notes:

  • All set operations trigger sync with the platform (with throttling);
  • Avoid excessive calls — batch changes where possible.

❌ Delete Data

del(k)

Delete a specific key and sync changes to the platform.

js
window.playolSDK.data.del('config')

🧹 Clear All Data

clear()

Erase all stored data for the current user. Use with caution.

js
window.playolSDK.data.clear()

📌 Notes:

  • This operation is irreversible — typically used during logout or account reset;
  • Always confirm user intent before calling.

⚙️ 3. Sync Mechanism Explained

  • All set, del, and clear actions trigger automatic data uploads;
  • The SDK uses debounced sync — changes within 1 second are batched; max delay is 30 seconds;
  • Each user has a 1MB storage limit — if exceeded, uploads are halted and warnings logged;
  • Sync is tied to the authenticated account — guest users do not benefit from cross-device sync.

ScenarioSuggested Method
Save current levelset('currentLevel', 5)
Load all configgetAll()
Remove a single settingdel('volume')
Full game resetclear()
Auto-save after UI changeCall set() after interaction
Fetch progress on loadget() / getAll()

📦 5. FAQ

Q: Is data saved in real time?

A: The SDK syncs automatically. Uploads are triggered within ~1s, but no later than 30s.

Q: Will set() overwrite existing data?

A: Yes. Repeated calls with the same key will overwrite the previous value.

Q: Can guest users use the data module?

A: Yes, but only for local use — cloud sync is not available for guests.

Q: Will I be notified if storage fails?

A: Yes. Warnings or errors (e.g., size exceeded) will be logged in the browser console.


👉 User ModuleGame ModulePayment ModuleInvite Module

Released under the MIT License