Simplified, typed wrapper around browser.storage APIs with reactive-like interface for managing extension state.
/**
* Simplified storage APIs with support for versioned fields, snapshots,
* metadata, and item definitions.
*
* See [the guide](https://wxt.dev/storage.html) for more information.
*
* @module @wxt-dev/storage
*/
import { browser, type Browser } from '@wxt-dev/browser';
import { withLock } from 'superlock';
import { dequal } from 'dequal/lite';
export const storage = createStorage();
function createStorage(): WxtStorage {
const drivers: Record<StorageArea, WxtStorageDriver> = {
local: createDriver('local'),
session: createDriver('session'),
sync: createDriver('sync'),
managed: createDriver('managed'),
};
const getDriver = (area: StorageArea) => {
const driver = drivers[area];
if (driver == null) {
const areaNames = Object.keys(drivers).join(',
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key