Device Storage
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 thestringvalue for the key, orundefinedif not set.async
await zw.deviceStorage.set(key: string, value: string)→ saves astringvalue 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)→ returnstrueif the key exists, otherwisefalse.async
await zw.deviceStorage.getAll()→ returns an object of key–value pairs{ [key: string]: string }.
Adding Secrets
For passwords, API tokens, and other sensitive values, add them in the Desktop Agent UI instead of saving them as plain text in the Write JS building block using zw.deviceStorage.set(). (Reading a value with zw.deviceStorage.get() is safe.)
To add a secret:
Open the Desktop Agent.
Select Device storage from the tray menu.
Click Add key, then save your value.

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.
Logging Secrets
If you need to log sensitive values (like passwords or API tokens), use zw.logTemp() instead of zw.log(). zw.logTemp() shows the value in the live run logs, but it is not saved to TaskBot run reports.
⚠️ Avoid using zw.deviceStorage.get() to read secrets via Code in Inputs in no-code building blocks. Many building blocks auto-log values, and those logs are saved to TaskBot run reports.
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 inzw.deviceStorage.*are async, whether the code runs locally or in the browser.
Last updated