Skip to content

API / wxt/utils/storage / WxtStorageItem

Interface: WxtStorageItem<TValue, TMetadata>

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

Contents

Type Parameters

TValue

TValue

TMetadata

TMetadata extends Record<string, unknown>

Properties

defaultValue

defaultValue: TValue

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

Deprecated

Renamed to fallback, use it instead.


fallback

fallback: TValue

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

The value provided by the fallback option.


key

key: `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}`

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

The storage key passed when creating the storage item.

Methods

getMeta()

getMeta(): Promise<NullablePartial<TMetadata>>

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

Get metadata.

Returns

Promise<NullablePartial<TMetadata>>


getValue()

getValue(): Promise<TValue>

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

Get the latest value from storage.

Returns

Promise<TValue>


migrate()

migrate(): Promise<void>

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

If there are migrations defined on the storage item, migrate to the latest version.

This function is ran automatically whenever the extension updates, so you don't have to call it manually.

Returns

Promise<void>


removeMeta()

removeMeta(properties?): Promise<void>

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

Remove all metadata or certain properties from metadata.

Parameters

properties?

string[]

Returns

Promise<void>


removeValue()

removeValue(opts?): Promise<void>

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

Remove the value from storage.

Parameters

opts?

RemoveItemOptions

Returns

Promise<void>


setMeta()

setMeta(properties): Promise<void>

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

Set metadata properties.

Parameters

properties

NullablePartial<TMetadata>

Returns

Promise<void>


setValue()

setValue(value): Promise<void>

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

Set the value in storage.

Parameters

value

TValue

Returns

Promise<void>


watch()

watch(cb): Unwatch

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

Listen for changes to the value in storage.

Parameters

cb

WatchCallback<TValue>

Returns

Unwatch


Generated using typedoc-plugin-markdown and TypeDoc