# UrlState

Reads and writes the shareable state in the page address, using the hash
and `history.replaceState` only, so history is never spammed. Writes are
debounced inside the real adapter. Parsing and serialising live in core.

This is an interface exported by `@mapcairn/core`, checked against version 0.2.0.

## Signature

```ts
import type { UrlState } from "@mapcairn/core";
 
interface UrlState
```

## Methods

### link

```ts
link(value: UrlStateValue): string;
```

The full address that would show `value`: this page's address with its
hash replaced by the one `value` makes. It changes nothing, so a link can
carry more than the address bar does.

- `value` (`UrlStateValue`)

### read

```ts
read(): UrlStateValue;
```

The shareable state the address holds now. A part that is missing or unreadable is left out.

### write

```ts
write(value: UrlStateValue): void;
```

Replaces the shareable state in the address. It does not merge with what is there.

- `value` (`UrlStateValue`)

## See also

- [`UrlStateValue`](https://docs.mapcairn.com/api/core/UrlStateValue.md)

Source: [packages/core/src/ports/url.ts:42](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/ports/url.ts#L42)
