Skip to main content

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 with plugin:{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

Every set() and setForPlugin() call emits a storage:change event:

Best Practices

Use Plugin-Scoped Storage

Store Positions

Store Settings

api.storage uses localStorage, which has a ~5MB limit per origin. Don’t store large blobs (images, long documents) — use IndexedDB for that.
The core registry uses board-plugins-registry — avoid that key.