vapor-chamber API reference - v1.16.0
    Preparing search index...

    Type Alias Router<TName>

    type Router<TName extends string = string> = {
        currentRoute: Readonly<ShallowRef<RouteSnapshot>>;
        routes: Readonly<ShallowRef<readonly TableRecord[]>>;
        base: string;
        isLoading: Readonly<ShallowRef<boolean>>;
        isRevalidating: Readonly<ShallowRef<boolean>>;
        lastError: ShallowRef<unknown>;
        push: (to: RouteLocationRaw<TName>) => Promise<RouterError | null>;
        replace: (to: RouteLocationRaw<TName>) => Promise<RouterError | null>;
        back: () => void;
        forward: () => void;
        go: (delta: number) => void;
        setQuery: (
            patch: QueryPatch,
            opts?: { history?: "push" | "replace" },
        ) => void;
        setRouteData: (recordName: string, value: unknown) => void;
        beforeEach: (guard: NavigationGuard) => () => void;
        afterEach: (hook: AfterEachHook) => () => void;
        onError: (
            handler: (error: unknown, to: RouteLocation) => void,
        ) => () => void;
        setRoutes: (rows: readonly RouteRecord[]) => void;
        reload: () => Promise<void>;
        start: () => Promise<void>;
        isReady: () => Promise<void>;
        resolve: (to: RouteLocationRaw<TName>) => string;
        install: (
            app: {
                provide: (key: symbol, value: unknown) => unknown;
                component: (name: string, comp: unknown) => unknown;
            },
        ) => void;
        destroy: () => void;
    }

    Type Parameters

    • TName extends string = string
    Index
    currentRoute: Readonly<ShallowRef<RouteSnapshot>>

    Reactive snapshot: .value.location (URL state), .value.render (outlets), .value.data (loader results). One frozen object per commit.

    routes: Readonly<ShallowRef<readonly TableRecord[]>>

    Reactive compiled route records — [] until the table is loaded, a new array on setRoutes()/reload(). Table projections (useMenu) read this.

    base: string

    The history base ('' or e.g. '/admin/it') — absolute hrefs are base + path.

    isLoading: Readonly<ShallowRef<boolean>>

    True while loaders run (navigations and query refetches).

    isRevalidating: Readonly<ShallowRef<boolean>>

    True while a stale-while-revalidate refresh runs behind data already on screen. Deliberately separate from isLoading: a stale hit commits real data, so the page is showing something, not waiting for it. Only ever true when a loader read opted into cache.staleTtl.

    lastError: ShallowRef<unknown>

    Latest navigation error (null after clear) — see useRouteError().

    push: (to: RouteLocationRaw<TName>) => Promise<RouterError | null>
    replace: (to: RouteLocationRaw<TName>) => Promise<RouterError | null>
    back: () => void
    forward: () => void
    go: (delta: number) => void
    setQuery: (patch: QueryPatch, opts?: { history?: "push" | "replace" }) => void
    setRouteData: (recordName: string, value: unknown) => void

    HOT PATH: patch a record's loader data directly (no loader run, no navigation) — for bus-command responses, websocket pushes, optimistic updates. One frozen snapshot, fully reactive.

    beforeEach: (guard: NavigationGuard) => () => void

    Registrations auto-dispose with the component scope when made inside setup(); call the returned unsubscriber yourself elsewhere.

    afterEach: (hook: AfterEachHook) => () => void
    onError: (handler: (error: unknown, to: RouteLocation) => void) => () => void
    setRoutes: (rows: readonly RouteRecord[]) => void
    reload: () => Promise<void>

    Re-fetch the table from the configured { url } source (admin tasks: deploys, permission changes). Coded error when no url is configured.

    start: () => Promise<void>
    isReady: () => Promise<void>
    resolve: (to: RouteLocationRaw<TName>) => string

    Absolute href (base included) for plain .

    install: (
        app: {
            provide: (key: symbol, value: unknown) => unknown;
            component: (name: string, comp: unknown) => unknown;
        },
    ) => void
    destroy: () => void