Data Methodsstorage.set

storage.set

Writes one value to your app's own storage on the phone.

Writes a text value by key. A write that would pass the app's quota is refused with ok: false, never an error.

PropertyValue
ScopeNone (open method)
Who can use itAny developer
StatusAvailable

Parameters

NameTypeRequiredDescription
keystringYesA key is 1 to 128 characters: letters, digits and . _ : -.
valuestringYesText up to 65,536 characters. The whole app may keep about 256 KB in total.

Result

FieldTypeDescription
okbooleanfalse with reason: "quota" when the write did not fit.
reasonstringPresent only with ok: false.

Errors

CodeWhen
-32602A parameter is missing, has the wrong type or is over its limit.
4200Storage cannot be written: there is no signed-in account, or the device store failed.
4290More than 30 requests in 10 seconds.

See Error Codes for every code and how they reach your page.

Example

js
const r = await window.aksa.request({
  method: "storage.set",
  params: { key: "state", value: JSON.stringify(state) },
});
if (!r.ok) showQuotaMessage();

With AksaMini

If your page embeds aksa-mini.js, use its wrapper:

js
await AksaMini.store.setJSON("state", state);

Notes

  • Check ok. A full quota is a normal result, so handle it instead of assuming the save worked.
  • Use this instead of localStorage: served apps run in a sandbox where direct DOM storage may not work.
  • With no signed-in account the host answers 4200 for a write.

Used By

Ready To Build Or Ship?

Check your files, preview on an iPhone frame, and submit in the Developer Studio.