Overview
api.storage is a thin wrapper over localStorage with automatic JSON serialization.
API
api.storage.get(key)
Retrieve a value. Returns null if the key doesn’t exist.
api.storage.set(key, value)
Store a value. Automatically serializes to JSON. Emits a storage:change event.
api.storage.remove(key)
Delete a stored key.
api.storage.list()
Returns an array of all localStorage keys.
api.storage.clear()
Clears all localStorage data. Use with extreme caution.
Plugin-Scoped Storage
Instead of manually prefixing keys, use the plugin-scoped methods. They automatically prefix withplugin:{pluginId}:.
api.storage.getForPlugin(pluginId, key)
api.storage.setForPlugin(pluginId, key, value)
The Sample Theme plugin uses
setForPlugin/getForPlugin to persist theme settings with automatic key scoping.Storage Change Events
Everyset() and setForPlugin() call emits a storage:change event:
| Field | Description |
|---|---|
key | The storage key (full key, including plugin: prefix for scoped storage) |
value | The new value |
oldValue | The previous value |
pluginId | (only for setForPlugin) The plugin that made the change |
Best Practices
Use Plugin-Scoped Storage
Store Positions
Store Settings
The core registry uses
board-plugins-registry — avoid that key.