Skip to content

API > wxt/utils/storage > WxtStorage

Interface: WxtStorage

Contents

Methods

clear()

clear(base): Promise<void>

Removes all items from the provided storage area.

Parameters

base: StorageArea

Source

packages/storage/dist/index.d.mts:454


defineItem()

defineItem(key)

defineItem<TValue, TMetadata, TKey>(key): object

Define a storage item with a default value, type, or versioning.

Read full docs: https://wxt.dev/storage.html#defining-storage-items

Type parameters

TValue

TMetadata extends Record<string, unknown> = Record<string, unknown>

TKey extends `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}` = `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}`

Parameters

key: TKey

Returns
area

readonly area: TKey extends `${A}😒{string}` ? A : StorageArea

The storage area, derived at the type level from the key prefix ('local:x''local'). Runtime value mirrors driver.area.

debug

readonly debug: false

The debug flag as captured at define-time.

defaultValue

defaultValue: null

Deprecated

Renamed to fallback, use it instead.

fallback

fallback: null

The fallback option value, preserved as its literal type where possible (fallback: 'system' as const → typed 'system').

key

key: TKey

The storage key passed to defineItem. String-literal keys narrow to that literal; wider StorageItemKey values stay as the union.

onValidationError

readonly onValidationError: OnValidationError<null | TValue>

The onValidationError policy in effect at read-time.

schema

readonly schema: undefined

The schema passed at define-time, or undefined.

version

readonly version: number

The schema version, captured as a numeric literal when passed directly.

getMeta()

Get metadata.

getValue()

Get the latest value from storage.

migrate()

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.

removeMeta()

Remove all metadata or certain properties from metadata.

Parameters

properties?: string[]

removeValue()

Remove the value from storage.

Parameters

opts?: RemoveItemOptions

setMeta()

Set metadata properties.

Parameters

properties: NullablePartial<TMetadata>

setValue()

Set the value in storage.

Parameters

value: null | TValue

watch()

Listen for changes to the value in storage.

Parameters

cb: WatchCallback<null | TValue>

Source

packages/storage/dist/index.d.mts:483

defineItem(key, options)

defineItem<TSchema, TMetadata, TKey, TRaw, TFallback, TVersion, TMigrations, TDebug>(key, options): object

Type parameters

TSchema extends StandardSchemaV1<unknown, unknown>

TMetadata extends Record<string, unknown> = Record<string, unknown>

TKey extends `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}` = `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}`

TRaw = unknown

TFallback = InferOutput<TSchema>

TVersion extends number = number

TMigrations extends readonly MigrationFn[] | readonly [] = MigrationTuple<TVersion>

TDebug extends boolean = false

Parameters

key: TKey

options: Omit<WxtStorageItemOptions<InferOutput<TSchema>, TRaw, TVersion>, "migrations"> & object

Returns
area

readonly area: TKey extends `${A}😒{string}` ? A : StorageArea

The storage area, derived at the type level from the key prefix ('local:x''local'). Runtime value mirrors driver.area.

debug

readonly debug: TDebug

The debug flag as captured at define-time.

defaultValue

defaultValue: TFallback

Deprecated

Renamed to fallback, use it instead.

fallback

fallback: TFallback

The fallback option value, preserved as its literal type where possible (fallback: 'system' as const → typed 'system').

key

key: TKey

The storage key passed to defineItem. String-literal keys narrow to that literal; wider StorageItemKey values stay as the union.

onValidationError

readonly onValidationError: OnValidationError<InferOutput<TSchema>>

The onValidationError policy in effect at read-time.

schema

readonly schema: TSchema

The schema passed at define-time, or undefined.

version

readonly version: TVersion

The schema version, captured as a numeric literal when passed directly.

getMeta()

Get metadata.

getValue()

Get the latest value from storage.

migrate()

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.

removeMeta()

Remove all metadata or certain properties from metadata.

Parameters

properties?: string[]

removeValue()

Remove the value from storage.

Parameters

opts?: RemoveItemOptions

setMeta()

Set metadata properties.

Parameters

properties: NullablePartial<TMetadata>

setValue()

Set the value in storage.

Parameters

value: InferOutput<TSchema>

watch()

Listen for changes to the value in storage.

Parameters

cb: WatchCallback<InferOutput<TSchema>>

Source

packages/storage/dist/index.d.mts:484

defineItem(key, options)

defineItem<TSchema, TMetadata, TKey, TRaw, TFallback, TVersion, TMigrations, TDebug>(key, options): object

Type parameters

TSchema extends StandardSchemaV1<unknown, unknown>

TMetadata extends Record<string, unknown> = Record<string, unknown>

TKey extends `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}` = `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}`

TRaw = unknown

TFallback = InferOutput<TSchema>

TVersion extends number = number

TMigrations extends readonly [] | readonly MigrationFn[] = MigrationTuple<TVersion>

TDebug extends boolean = false

Parameters

key: TKey

options: Omit<WxtStorageItemOptions<InferOutput<TSchema>, TRaw, TVersion>, "migrations"> & object

Returns
area

readonly area: TKey extends `${A}😒{string}` ? A : StorageArea

The storage area, derived at the type level from the key prefix ('local:x''local'). Runtime value mirrors driver.area.

debug

readonly debug: TDebug

The debug flag as captured at define-time.

defaultValue

defaultValue: TFallback

Deprecated

Renamed to fallback, use it instead.

fallback

fallback: TFallback

The fallback option value, preserved as its literal type where possible (fallback: 'system' as const → typed 'system').

key

key: TKey

The storage key passed to defineItem. String-literal keys narrow to that literal; wider StorageItemKey values stay as the union.

onValidationError

readonly onValidationError: OnValidationError<InferOutput<TSchema>>

The onValidationError policy in effect at read-time.

schema

readonly schema: TSchema

The schema passed at define-time, or undefined.

version

readonly version: TVersion

The schema version, captured as a numeric literal when passed directly.

getMeta()

Get metadata.

getValue()

Get the latest value from storage.

migrate()

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.

removeMeta()

Remove all metadata or certain properties from metadata.

Parameters

properties?: string[]

removeValue()

Remove the value from storage.

Parameters

opts?: RemoveItemOptions

setMeta()

Set metadata properties.

Parameters

properties: NullablePartial<TMetadata>

setValue()

Set the value in storage.

Parameters

value: InferOutput<TSchema>

watch()

Listen for changes to the value in storage.

Parameters

cb: WatchCallback<InferOutput<TSchema>>

Source

packages/storage/dist/index.d.mts:490

defineItem(key, options)

defineItem<TSchema, TMetadata, TKey, TRaw, TVersion, TMigrations, TDebug>(key, options): object

Type parameters

TSchema extends StandardSchemaV1<unknown, unknown>

TMetadata extends Record<string, unknown> = Record<string, unknown>

TKey extends `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}` = `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}`

TRaw = unknown

TVersion extends number = number

TMigrations extends readonly [] | readonly MigrationFn[] = MigrationTuple<TVersion>

TDebug extends boolean = false

Parameters

key: TKey

options: Omit<WxtStorageItemOptions<InferOutput<TSchema>, TRaw, TVersion>, "migrations"> & object

Returns
area

readonly area: TKey extends `${A}😒{string}` ? A : StorageArea

The storage area, derived at the type level from the key prefix ('local:x''local'). Runtime value mirrors driver.area.

debug

readonly debug: TDebug

The debug flag as captured at define-time.

defaultValue

defaultValue: null

Deprecated

Renamed to fallback, use it instead.

fallback

fallback: null

The fallback option value, preserved as its literal type where possible (fallback: 'system' as const → typed 'system').

key

key: TKey

The storage key passed to defineItem. String-literal keys narrow to that literal; wider StorageItemKey values stay as the union.

onValidationError

readonly onValidationError: OnValidationError<InferOutput<TSchema>>

The onValidationError policy in effect at read-time.

schema

readonly schema: TSchema

The schema passed at define-time, or undefined.

version

readonly version: TVersion

The schema version, captured as a numeric literal when passed directly.

getMeta()

Get metadata.

getValue()

Get the latest value from storage.

migrate()

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.

removeMeta()

Remove all metadata or certain properties from metadata.

Parameters

properties?: string[]

removeValue()

Remove the value from storage.

Parameters

opts?: RemoveItemOptions

setMeta()

Set metadata properties.

Parameters

properties: NullablePartial<TMetadata>

setValue()

Set the value in storage.

Parameters

value: InferOutput<TSchema>

watch()

Listen for changes to the value in storage.

Parameters

cb: WatchCallback<InferOutput<TSchema>>

Source

packages/storage/dist/index.d.mts:496

defineItem(key, options)

defineItem<TSchema, TMetadata, TKey, TRaw, TVersion, TMigrations, TDebug>(key, options): object

Type parameters

TSchema extends StandardSchemaV1<unknown, unknown>

TMetadata extends Record<string, unknown> = Record<string, unknown>

TKey extends `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}` = `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}`

TRaw = unknown

TVersion extends number = number

TMigrations extends readonly [] | readonly MigrationFn[] = MigrationTuple<TVersion>

TDebug extends boolean = false

Parameters

key: TKey

options: Omit<WxtStorageItemOptions<InferOutput<TSchema>, TRaw, TVersion>, "migrations"> & object

Returns
area

readonly area: TKey extends `${A}😒{string}` ? A : StorageArea

The storage area, derived at the type level from the key prefix ('local:x''local'). Runtime value mirrors driver.area.

debug

readonly debug: TDebug

The debug flag as captured at define-time.

defaultValue

defaultValue: null

Deprecated

Renamed to fallback, use it instead.

fallback

fallback: null

The fallback option value, preserved as its literal type where possible (fallback: 'system' as const → typed 'system').

key

key: TKey

The storage key passed to defineItem. String-literal keys narrow to that literal; wider StorageItemKey values stay as the union.

onValidationError

readonly onValidationError: OnValidationError<null | InferOutput<TSchema>>

The onValidationError policy in effect at read-time.

schema

readonly schema: TSchema

The schema passed at define-time, or undefined.

version

readonly version: TVersion

The schema version, captured as a numeric literal when passed directly.

getMeta()

Get metadata.

getValue()

Get the latest value from storage.

migrate()

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.

removeMeta()

Remove all metadata or certain properties from metadata.

Parameters

properties?: string[]

removeValue()

Remove the value from storage.

Parameters

opts?: RemoveItemOptions

setMeta()

Set metadata properties.

Parameters

properties: NullablePartial<TMetadata>

setValue()

Set the value in storage.

Parameters

value: null | InferOutput<TSchema>

watch()

Listen for changes to the value in storage.

Parameters

cb: WatchCallback<null | InferOutput<TSchema>>

Source

packages/storage/dist/index.d.mts:502

defineItem(key, options)

defineItem<TValue, TMetadata, TKey, TRaw, TFallback, TVersion, TMigrations, TDebug>(key, options): object

Type parameters

TValue

TMetadata extends Record<string, unknown> = Record<string, unknown>

TKey extends `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}` = `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}`

TRaw = unknown

TFallback = Widen<TValue>

TVersion extends number = number

TMigrations extends readonly [] | readonly MigrationFn[] = MigrationTuple<TVersion>

TDebug extends boolean = false

Parameters

key: TKey

options: Omit<WxtStorageItemOptions<TValue, TRaw, TVersion>, "migrations"> & object

Returns
area

readonly area: TKey extends `${A}😒{string}` ? A : StorageArea

The storage area, derived at the type level from the key prefix ('local:x''local'). Runtime value mirrors driver.area.

debug

readonly debug: TDebug

The debug flag as captured at define-time.

defaultValue

defaultValue: TFallback

Deprecated

Renamed to fallback, use it instead.

fallback

fallback: TFallback

The fallback option value, preserved as its literal type where possible (fallback: 'system' as const → typed 'system').

key

key: TKey

The storage key passed to defineItem. String-literal keys narrow to that literal; wider StorageItemKey values stay as the union.

onValidationError

readonly onValidationError: OnValidationError<Widen<TValue>>

The onValidationError policy in effect at read-time.

schema

readonly schema: undefined

The schema passed at define-time, or undefined.

version

readonly version: TVersion

The schema version, captured as a numeric literal when passed directly.

getMeta()

Get metadata.

getValue()

Get the latest value from storage.

migrate()

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.

removeMeta()

Remove all metadata or certain properties from metadata.

Parameters

properties?: string[]

removeValue()

Remove the value from storage.

Parameters

opts?: RemoveItemOptions

setMeta()

Set metadata properties.

Parameters

properties: NullablePartial<TMetadata>

setValue()

Set the value in storage.

Parameters

value: Widen<TValue>

watch()

Listen for changes to the value in storage.

Parameters

cb: WatchCallback<Widen<TValue>>

Source

packages/storage/dist/index.d.mts:507

defineItem(key, options)

defineItem<TValue, TMetadata, TKey, TRaw, TFallback, TVersion, TMigrations, TDebug>(key, options): object

Type parameters

TValue

TMetadata extends Record<string, unknown> = Record<string, unknown>

TKey extends `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}` = `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}`

TRaw = unknown

TFallback = Widen<TValue>

TVersion extends number = number

TMigrations extends readonly [] | readonly MigrationFn[] = MigrationTuple<TVersion>

TDebug extends boolean = false

Parameters

key: TKey

options: Omit<WxtStorageItemOptions<TValue, TRaw, TVersion>, "migrations"> & object

Returns
area

readonly area: TKey extends `${A}😒{string}` ? A : StorageArea

The storage area, derived at the type level from the key prefix ('local:x''local'). Runtime value mirrors driver.area.

debug

readonly debug: TDebug

The debug flag as captured at define-time.

defaultValue

defaultValue: TFallback

Deprecated

Renamed to fallback, use it instead.

fallback

fallback: TFallback

The fallback option value, preserved as its literal type where possible (fallback: 'system' as const → typed 'system').

key

key: TKey

The storage key passed to defineItem. String-literal keys narrow to that literal; wider StorageItemKey values stay as the union.

onValidationError

readonly onValidationError: OnValidationError<Widen<TValue>>

The onValidationError policy in effect at read-time.

schema

readonly schema: undefined

The schema passed at define-time, or undefined.

version

readonly version: TVersion

The schema version, captured as a numeric literal when passed directly.

getMeta()

Get metadata.

getValue()

Get the latest value from storage.

migrate()

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.

removeMeta()

Remove all metadata or certain properties from metadata.

Parameters

properties?: string[]

removeValue()

Remove the value from storage.

Parameters

opts?: RemoveItemOptions

setMeta()

Set metadata properties.

Parameters

properties: NullablePartial<TMetadata>

setValue()

Set the value in storage.

Parameters

value: Widen<TValue>

watch()

Listen for changes to the value in storage.

Parameters

cb: WatchCallback<Widen<TValue>>

Source

packages/storage/dist/index.d.mts:512

defineItem(key, options)

defineItem<TValue, TMetadata, TKey, TRaw, TVersion, TMigrations, TDebug>(key, options): object

Type parameters

TValue

TMetadata extends Record<string, unknown> = Record<string, unknown>

TKey extends `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}` = `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}`

TRaw = unknown

TVersion extends number = number

TMigrations extends readonly [] | readonly MigrationFn[] = MigrationTuple<TVersion>

TDebug extends boolean = false

Parameters

key: TKey

options: Omit<WxtStorageItemOptions<TValue, TRaw, TVersion>, "migrations"> & object

Returns
area

readonly area: TKey extends `${A}😒{string}` ? A : StorageArea

The storage area, derived at the type level from the key prefix ('local:x''local'). Runtime value mirrors driver.area.

debug

readonly debug: TDebug

The debug flag as captured at define-time.

defaultValue

defaultValue: null

Deprecated

Renamed to fallback, use it instead.

fallback

fallback: null

The fallback option value, preserved as its literal type where possible (fallback: 'system' as const → typed 'system').

key

key: TKey

The storage key passed to defineItem. String-literal keys narrow to that literal; wider StorageItemKey values stay as the union.

onValidationError

readonly onValidationError: OnValidationError<Widen<TValue>>

The onValidationError policy in effect at read-time.

schema

readonly schema: undefined

The schema passed at define-time, or undefined.

version

readonly version: TVersion

The schema version, captured as a numeric literal when passed directly.

getMeta()

Get metadata.

getValue()

Get the latest value from storage.

migrate()

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.

removeMeta()

Remove all metadata or certain properties from metadata.

Parameters

properties?: string[]

removeValue()

Remove the value from storage.

Parameters

opts?: RemoveItemOptions

setMeta()

Set metadata properties.

Parameters

properties: NullablePartial<TMetadata>

setValue()

Set the value in storage.

Parameters

value: Widen<TValue>

watch()

Listen for changes to the value in storage.

Parameters

cb: WatchCallback<Widen<TValue>>

Source

packages/storage/dist/index.d.mts:517

defineItem(key, options)

defineItem<TValue, TMetadata, TKey, TRaw, TVersion, TMigrations, TDebug>(key, options): object

Type parameters

TValue

TMetadata extends Record<string, unknown> = Record<string, unknown>

TKey extends `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}` = `local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}`

TRaw = unknown

TVersion extends number = number

TMigrations extends readonly [] | readonly MigrationFn[] = MigrationTuple<TVersion>

TDebug extends boolean = false

Parameters

key: TKey

options: Omit<WxtStorageItemOptions<TValue, TRaw, TVersion>, "migrations"> & object

Returns
area

readonly area: TKey extends `${A}😒{string}` ? A : StorageArea

The storage area, derived at the type level from the key prefix ('local:x''local'). Runtime value mirrors driver.area.

debug

readonly debug: TDebug

The debug flag as captured at define-time.

defaultValue

defaultValue: null

Deprecated

Renamed to fallback, use it instead.

fallback

fallback: null

The fallback option value, preserved as its literal type where possible (fallback: 'system' as const → typed 'system').

key

key: TKey

The storage key passed to defineItem. String-literal keys narrow to that literal; wider StorageItemKey values stay as the union.

onValidationError

readonly onValidationError: OnValidationError<null | Widen<TValue>>

The onValidationError policy in effect at read-time.

schema

readonly schema: undefined

The schema passed at define-time, or undefined.

version

readonly version: TVersion

The schema version, captured as a numeric literal when passed directly.

getMeta()

Get metadata.

getValue()

Get the latest value from storage.

migrate()

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.

removeMeta()

Remove all metadata or certain properties from metadata.

Parameters

properties?: string[]

removeValue()

Remove the value from storage.

Parameters

opts?: RemoveItemOptions

setMeta()

Set metadata properties.

Parameters

properties: NullablePartial<TMetadata>

setValue()

Set the value in storage.

Parameters

value: null | Widen<TValue>

watch()

Listen for changes to the value in storage.

Parameters

cb: WatchCallback<null | Widen<TValue>>

Source

packages/storage/dist/index.d.mts:522


getItem()

getItem(key, opts)

getItem<TValue>(key, opts): Promise<WritableDeep<TValue>>

Get an item from storage, or return null if it doesn't exist.

The overload without a fallback returns Promise<unknown> — the value is whatever bytes storage happens to hold. Narrow the return type at the call site with a schema or an explicit assertion.

When opts.fallback is provided, TValue is inferred from the fallback and drives the return type honestly (fallback and return both share TValue), so no cast is needed.

Type parameters

TValue

Parameters

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

opts: GetItemOptions<TValue> & object

Returns
Example
ts
const raw = await storage.getItem('local:installDate');
  // raw: unknown
  const withFallback = await storage.getItem('local:count', {
    fallback: 0,
  });
  // withFallback: number
Source

packages/storage/dist/index.d.mts:360

getItem(key, opts)

getItem(key, opts?): Promise<unknown>

Parameters

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

opts?: GetItemOptions<unknown>

Source

packages/storage/dist/index.d.mts:363


getItems()

getItems<T>(keys): Promise<GetItemsResult<T>>

Get multiple items from storage. The return order is guaranteed to be the same as the order requested.

Type parameters

T extends readonly GetItemsInputElement[]

Parameters

keys: T

Returns

Example

ts
await storage.getItems(['local:installDate', 'session:someCounter']);

Source

packages/storage/dist/index.d.mts:371


getMeta()

getMeta(key): Promise<Record<string, unknown>>

Return an object containing metadata about the key. Object is stored at key + "$". If value is not an object, it returns an empty object.

Returns Record<string, unknown> — metadata is arbitrary at the storage layer. Narrow at the call site if you need a specific shape.

Parameters

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

Returns

Example

ts
await storage.getMeta('local:installDate');

Source

packages/storage/dist/index.d.mts:382


getMetas()

getMetas<T>(keys): Promise<GetMetasResult<T>>

Get the metadata of multiple storage items.

Type parameters

T extends readonly GetMetasInputElement[]

Parameters

keys: T

List of keys or items to get the metadata of.

Returns

An array containing storage keys and their metadata.

Source

packages/storage/dist/index.d.mts:389


removeItem()

removeItem(key, opts?): Promise<void>

Removes an item from storage.

Parameters

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

opts?: RemoveItemOptions

Returns

Example

ts
await storage.removeItem('local:installDate');

Source

packages/storage/dist/index.d.mts:444


removeItems()

removeItems(keys): Promise<void>

Remove a list of keys from storage.

Parameters

keys: (`local:${string}` | `session:${string}` | `sync:${string}` | `managed:${string}` | WxtStorageItem<any, any, any, any, any, any, any> | object | object)[]

Source

packages/storage/dist/index.d.mts:446


removeMeta()

removeMeta(key, properties?): Promise<void>

Remove the entire metadata for a key, or specific properties by name.

Parameters

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

properties?: string | string[]

Returns

Example

ts
// Remove all metadata properties from the item
  await storage.removeMeta('local:installDate');

  // Remove only specific the "v" field
  await storage.removeMeta('local:installDate', 'v');

Source

packages/storage/dist/index.d.mts:465


restoreSnapshot()

restoreSnapshot(base, data): Promise<void>

Restores the results of snapshot. If new properties have been saved since the snapshot, they are not overridden. Only values existing in the snapshot are overridden.

Parameters

base: StorageArea

data: Record<string, unknown>

Source

packages/storage/dist/index.d.mts:473


setItem()

setItem(key, value): Promise<void>

Set a value in storage. Setting a value to null or undefined is equivalent to calling removeItem.

Accepts unknown — the value goes to storage as-is. If you want type- checked writes, define the item via defineItem with a schema.

Parameters

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

value: unknown

Returns

Example

ts
await storage.setItem('local:installDate', Date.now());

Source

packages/storage/dist/index.d.mts:400


setItems()

setItems(values): Promise<void>

Set multiple values in storage. If a value is set to null or undefined, the key is removed.

Parameters

values: readonly (object | object)[]

Returns

Example

ts
await storage.setItem([
  { key: "local:installDate", value: Date.now() },
  { key: "session:someCounter, value: 5 },
  ]);

Source

packages/storage/dist/index.d.mts:411


setMeta()

setMeta(key, properties): Promise<void>

Sets metadata properties. If some properties are already set, but are not included in the properties parameter, they will not be removed.

Parameters

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

properties: null | Record<string, unknown>

Returns

Example

ts
await storage.setMeta('local:installDate', { appVersion });

Source

packages/storage/dist/index.d.mts:425


setMetas()

setMetas(metas): Promise<void>

Set the metadata of multiple storage items.

Parameters

metas: readonly (object | object)[]

List of storage keys or items and metadata to set for each.

Source

packages/storage/dist/index.d.mts:431


snapshot()

snapshot(base, opts?): Promise<Record<string, unknown>>

Return all the items in storage.

Parameters

base: StorageArea

opts?: SnapshotOptions

Source

packages/storage/dist/index.d.mts:467


unwatch()

unwatch(): void

Remove all watch listeners.

Source

packages/storage/dist/index.d.mts:477


watch()

watch(key, cb): Unwatch

Watch for changes to a specific key in storage.

Parameters

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

cb: WatchCallback<unknown>

Source

packages/storage/dist/index.d.mts:475


Generated using typedoc-plugin-markdown and TypeDoc