Skip to content
Persist
Esc
navigateopen⌘Jpreview

Choosing a codec

Pick a Persist wire format — Set/Map/Date, schema validation, or structured-clone backends.

localStorage stays JSON by default. Reach for seroval when Set/Map/Date must round-trip; Standard Schema when invalid prefs must never write; identityCodec only with structured-clone backends (IDB) — never string-wire.

Codec Set/Map/Date Wire type Schema validation For backend Subpath
jsonCodec string string-wire core
serovalCodec string (JSON-shaped) string-wire ./codecs/seroval
standardSchemaCodec ❌ (JSON wire; only via schema transforms) string string-wire ./codecs/standard-schema
identityCodec ✅ (structured clone) StorageValue<S> (object) structured-clone only (IDB) core
custom StorageCodec yours yours yours any custom encode/decode

standardSchemaCodec is sync ~standard over JSON. Prefer withStandardSchema / withStandardSchemaAsync over any PersistStorage when you need non-JSON compose or async validate — recipe. Composition: The three seams.

Last updated on July 22, 2026

Was this page helpful?