parseHydrationData
Parses text produced by serializeHydrationData.
Parses text produced by serializeHydrationData.
Import#
ts
import { parseHydrationData } from "@shadow-js/router";
Signature#
ts
function parseHydrationData(text: string): HydrationData
Parameters#
| Name | Description |
|---|---|
text |
JSON text. |
Returns#
The data, ready for router.hydrate.
Throws#
- TypeError when the text is not hydration data.
Examples#
ts
import { parseHydrationData } from "@shadow-js/router";
const data = parseHydrationData(text); // text: the JSON of the __shadow_data script element
router.hydrate(data);