Chuyển tới nội dung chính

SDK 1.0.0

Storage

Permission: storage. A small key/value store, private to your mini app and kept on the device.

await sdk.storage.set('progress', JSON.stringify({ level: 3 })) // values are strings only
const raw = await sdk.storage.get('progress') // string | null
const progress = raw ? JSON.parse(raw) : null

await sdk.storage.remove('progress')
await sdk.storage.clear() // everything this mini app stored
Limit (STORAGE_LIMITS)Value
maxKeys100 keys
maxValueBytes4,096 bytes per value
maxTotalBytes512,000 bytes per mini app
maxKeyLength256 characters
  • A non-string value rejects with INVALID_PARAMS, so JSON.stringify it yourself.
  • Going over a limit rejects with ACTION_FAILED.
  • Do not store secrets. This is convenience storage, not a vault.