Skip to content

API / wxt/utils/storage / WxtStorageItemOptions

Interface: WxtStorageItemOptions<T>

Source: packages/storage/dist/index.d.mts:203

Contents

Type Parameters

T

T

Properties

debug?

optional debug?: boolean

Source: packages/storage/dist/index.d.mts:231

Print debug logs, such as migration process.

Default

ts
false

defaultValue?

optional defaultValue?: T

Source: packages/storage/dist/index.d.mts:205

Deprecated

Renamed to fallback, use it instead.


fallback?

optional fallback?: T

Source: packages/storage/dist/index.d.mts:207

Default value returned when getValue would otherwise return null.


init?

optional init?: () => T | Promise<T>

Source: packages/storage/dist/index.d.mts:214

If passed, a value in storage will be initialized immediately after defining the storage item. This function returns the value that will be saved to storage during the initialization process if a value doesn't already exist.

Returns

T | Promise<T>


migrations?

optional migrations?: Record<number, (oldValue) => any>

Source: packages/storage/dist/index.d.mts:225

A map of version numbers to the functions used to migrate the data to that version.


onMigrationComplete?

optional onMigrationComplete?: (migratedValue, targetVersion) => void

Source: packages/storage/dist/index.d.mts:233

A callback function that runs on migration complete.

Parameters

migratedValue

T

targetVersion

number

Returns

void


version?

optional version?: number

Source: packages/storage/dist/index.d.mts:220

Provide a version number for the storage item to enable migrations. When changing the version in the future, migration functions will be ran on application startup.


Generated using typedoc-plugin-markdown and TypeDoc