Serialize
The codec that carries values JSON can't across every server↔client boundary — the SSR state blob, server-function arguments and results, resume boundary props and cache seeds. Round-trips Date / Map / Set / bigint / URL / RegExp / undefined out of the box; defineTypeHandler adds your own types with type-guard-driven inference.
Installation
pnpm add @sigx/serializeAbout
@sigx/serialize is the low-level codec beneath SignalX's server↔client boundaries. Out of the box it round-trips Date, Map, Set, bigint, URL, RegExp and explicit undefined; defineTypeHandler adds your own types. It has zero runtime dependencies by design — it's imported by the dependency-free @sigx/server/client stub — and is side-effect-free.
Two functions do the work — encodeWithHandlers and reviveWithHandlers — but most apps never call them directly: the server renderer, server functions and resume all run the codec for you. You reach for this package only to register a custom type — see Usage.
On the wire, a handled value takes a single-key tagged form:
{ "createdAt": { "$date": 1700000000000 }, "tags": { "$set": ["priority"] } }
Next steps
- Usage — write and register a custom type handler.
- API reference —
defineTypeHandler,encodeWithHandlers,reviveWithHandlers,TypeHandlerand the built-ins.
