deserialize
Restore a serialized hydration snapshot.
Compatibility
ReactAvailable in this renderer's browser integration.
React SSRClient-side setup for an SSR application; do not execute on the server.
PreactAvailable in this renderer's browser integration.
Preact SSRClient-side setup for an SSR application; do not execute on the server.
Import from @kasperrt/smolter/react/client @kasperrt/smolter/preact/client
Signature
function deserialize(json: string): Snapshot;Parameters
value is the JSON text produced by serialize.
Returns
A Snapshot with any serialized error restored to an Error object.
Usage
Import this API from one of the entry points listed above. Keep server and build helpers in their dedicated subpaths.
const snapshot = deserialize(element.textContent!);
const router = createDataRouter(routes, { hydrationData: snapshot });Behavior and edge cases
Use trusted snapshot text from your server. Invalid JSON throws; this function does not validate arbitrary input. Restored errors preserve their name and message without exposing server stack traces.