Device Storage (upcoming)

Available in version 1.1.72 (not yet live).

Persist key–value data on this device. Survives Desktop Agent restarts, uninstalls, and reinstalls. Stays on this device; data is never sent to ZeroWork servers.

API zw.deviceStorage.*

const credentials = {
  username: await zw.deviceStorage.get("username_salesforce"),
  password: await zw.deviceStorage.get("password_salesforce"),
};
await zw.deviceStorage.set("last_login_salesforce", String(Date.now()));

At a Glance

  • async await zw.deviceStorage.get(key: string) → returns the string value for the key, or undefined if not set.

  • async await zw.deviceStorage.set(key: string, value: string) → saves a string value under the key.

  • async await zw.deviceStorage.remove(key: string) → removes the key and its value from device storage.

  • async await zw.deviceStorage.has(key: string) → returns true if the key exists, otherwise false.

  • async await zw.deviceStorage.getAll() → returns an object of key–value pairs { [key: string]: string }.


Examples

Check if value is present and set if not

Securely log in with credentials stored only locally

Clear device storage


Saving Non-String Values

Device storage only accepts strings. You can stringify on write and parse on read if you want to work with other types.


Notes

  • Size limits. Total device storage is limited to ~3,000,000 characters. Writes that would exceed the total limit will throw an error.

  • Always use await. All methods in zw.deviceStorage.* are async, whether the code runs locally or in the browser.

Last updated

Was this helpful?