# memory

Provides Navigation from an in-memory history state.

## Signatures

```ts
export declare const memory: (options: MemoryOptions) => Layer.Layer<Navigation, never, Uuid7State>;
```

## Why

The same Router and application code can run during SSR or tests without browser globals. Back and
forward are bounded, `traverseTo` uses stable entry keys, and history retention is deterministic.
This constructor expects at least one entry, a positive `maxEntries`, and an active index that
survives tail retention. If truncation is needed, the active entry must lie in the newest
`maxEntries` entries; equivalently, `currentIndex >= entries.length - maxEntries`. These
preconditions are not validated. `maxEntries: 0` currently behaves as unbounded retention rather
than zero capacity. Use `initialMemory` for the common one-URL case.

## Ownership and lifetime

Layer acquisition creates the navigation state and handler registries; Layer release finalizes
their Scope. The Layer requires `Uuid7State` for newly committed destinations and fails with
`NavigationError` when identifier generation or a custom backend commit fails.

## Examples

```ts
import { memory } from "@typed/navigation/memory"
import type { Destination } from "@typed/navigation/model"

const entry: Destination = {
  id: "entry-1",
  key: "entry-1",
  url: new URL("https://example.com/products"),
  state: undefined,
  sameDocument: true
}
const NavigationLive = memory({ entries: [entry], currentIndex: 0, maxEntries: 50 })
```
