The Storage module provides a lightweight persistent key-value storage system for scripts. It allows scripts to save and retrieve simple typed data as well as binary data (Data). All data is persisted asynchronously in the background.
By default, all values are stored in the private domain of the current script, which means other scripts cannot access them. To share data across multiple scripts, set the shared: true option to use the shared domain instead.
The following types can be stored using the Storage API:
stringnumberbooleanJSON (any JSON-serializable structure)Data (using setData / getData)| Domain | Default | Accessible By | Use Case |
|---|---|---|---|
| Private | Yes | Only the current script | Script-specific settings, preferences, cached content |
| Shared | No (must pass shared: true) |
All scripts | Global settings, shared preferences, multi-script communication |
Storage.set(key, value, options?)Stores a value in persistent storage. Supports string, number, boolean, and JSON-serializable values.
| Name | Type | Required | Description |
|---|---|---|---|
| key | string |
Yes | The key under which the value is stored |
| value | T |
Yes | The value to store |
| options.shared | boolean |
No | Store the value in the shared domain when true |
boolean — whether the operation was successful.Storage.get(key, options?)Retrieves a stored value. Returns null if the key does not exist.
T | null — the value associated with the key or null.Storage.setData(key, data, options?)Stores a Data object in persistent storage.
Storage.getData(key, options?)Retrieves a stored Data object. Returns null if the key does not exist.
Storage.remove(key, options?)Removes the entry associated with the specified key.
Storage.contains(key, options?)Checks whether the storage contains the specified key.
Storage.clear()Removes all entries from the private storage domain. This does not affect shared storage.
Storage.keys()Returns an array of all keys stored in the current storage domain.
Data cannot be stored using Storage.set(). Use setData() / getData() instead.Storage.clear() only clears the private domain.