API > wxt/utils/storage > WxtStorageItemSerializer
Interface: WxtStorageItemSerializer<TValue, TRaw>
Two-way converter between the runtime value type and the wire form stored in chrome.storage. Naming (read / write) is verbatim from VueUse's useStorage serializer.
writeis required — it produces the value handed tochrome.storage.*.set.readis optional — if omitted, the raw value is passed straight toschema.validate(). This lets coerce schemas (e.g.z.coerce.date()) handle deserialization on their own.
Contents
Type parameters
▪ TValue
▪ TRaw = unknown
Properties
write
write: (
value) =>TRaw
Convert TValue to the wire form written to storage.
Parameters
▪ value: TValue
Source
packages/storage/dist/index.d.mts:81
Methods
read()
optionalread(raw):TValue
Convert the wire form read from storage back to TValue.
Declared as a method (shorthand syntax) so users may narrow the parameter without a cast: read(raw: MyWireType): TValue { ... }. Method params are checked bivariantly. Pipeline passes unknown from chrome.storage; the impl must narrow (schema or type guard). Matches the io-ts Type<A, O, I> pattern (decode input = I = unknown).
Parameters
▪ raw: unknown
Source
packages/storage/dist/index.d.mts:91
Generated using typedoc-plugin-markdown and TypeDoc