---
url: >-
  https://lit-ui-router.dev/reference/lit-ui-router-ssr/client/functions/readHydrationSignature.md
---
[lit-ui-router-ssr](../../index.md) / [client](../index.md) / readHydrationSignature

# Function: readHydrationSignature()

```ts
function readHydrationSignature(container): HydrationSignature | null;
```

Defined in: [packages/lit-ui-router-ssr/src/client.ts:647](https://github.com/simshanith/lit-ui-router/blob/6e47ef8d8a4b24e99c074fb5c8c9cfaddfdb36a4/packages/lit-ui-router-ssr/src/client.ts#L647)

Reads the hydration signature `prerender()` wrote ahead of the render a
container holds: the version of this package that drew the document, and
the state and parameter values it was drawn for.

The signature is a `<script type="application/json" data-lit-ui-router-ssr>`
data block among the container's own children, so this reads no deeper than
they are; the first one wins. It reads the same before and after a
[hydrateRoot](hydrateRoot.md) that adopts, which leaves the block in place; one that
returns `false` clears the container.

Only `version` is checked. `state` and `params` are whatever the block
carries, so narrow them before use. Read it before [hydrateRoot](hydrateRoot.md), which
clears a container it does not adopt.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `container` | `ParentNode` | the element the server's markup was written into |

## Returns

[`HydrationSignature`](../interfaces/HydrationSignature.md) | `null`

the signature, or `null` when the container holds none, or one that
does not parse to an object with a string `version`

## Example

```ts
import { hydrateRoot, readHydrationSignature } from 'lit-ui-router-ssr/client';
import type { TemplateResult } from 'lit';
import type { UIRouterLit } from 'lit-ui-router';

declare const booted: Promise<void>;
declare const root: HTMLElement;
declare const router: UIRouterLit;
declare function page(router: UIRouterLit): TemplateResult;

await booted;
const { state } = readHydrationSignature(root) ?? {};
const bootedWhereDrawn = state === router.globals.current.name;
const release = hydrateRoot(root, page(router));
```
