variable / @typed/router

redirectTo

Retries a Matcher or Fx once after navigating on RouteNotFound.

Prefer the fluent matcher.redirectTo(path) method when configuring a Matcher. This standalone form remains useful for inputs already expressed as Fx and for existing data-last pipelines.

Package version
1.0.0-beta.7
Category
Route recovery
Since
1.0.0

Import

import { redirectTo } from "@typed/router";

Signatures

export declare const redirectTo: (path: string) => <I extends Fx.Fx.Any | Matcher.Any>(input: I) => Fx.Fx<InputSucces<I>, Exclude<InputError<I>, RouteNotFound>, Router | Scope.Scope | InputServices<I>>;

Why

A fallback route can redirect without masking matched-handler failures or redirecting forever.

Ownership and lifetime

Calling redirectTo constructs an Fx and retains only the target string and input. Its single retry and Navigation operation run in the consumer Scope.

Examples

import * as Router from "@typed/router"

const app = Router.match(Router.Parse("/"), "home")
const withFallback = Router.redirectTo("/not-found")(app)

Other public imports

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

Source