variable / @typed/router/Router

BrowserRouter

Builds a browser Router Layer over the platform History API.

Package version
1.0.0-beta.7
Category
Runtime providers
Since
1.0.0

Import

import { BrowserRouter } from "@typed/router/Router";

Signatures

export declare const BrowserRouter: (window?: Window) => Layer.Layer<Router, NavigationError>;

Why

Browser programs receive the same Router contract as SSR and tests while preserving native history and popstate as the platform authority.

Ownership and lifetime

Layer acquisition installs the Navigation listener, provides random Uuid7State, and creates the root CurrentRoute. Layer release removes listeners and finalizes scoped registrations. Browser/history failures surface as NavigationError.

Examples

import * as Router from "@typed/router"
import { Navigation } from "@typed/navigation/Navigation"
import * as Effect from "effect/Effect"

const currentUrl = Effect.map(Navigation.currentEntry, ({ url }) => url)
const program = Effect.provide(currentUrl, Router.BrowserRouter(window))

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source