function / @typed/svelte

useNavigation

Native state plus promise commands using the closest Navigation service. Commands use the latest provider after runtime replacement.

Package version
1.0.0-beta.13
Category
function

Import

import { useNavigation } from "@typed/svelte";

Signatures

export declare function useNavigation<ER = never>(options?: SourceOptions<Destination, never, Navigation, ER>): {
    location: import("./AsyncData.js").AsyncState<{
        readonly id: string;
        readonly key: string;
        readonly url: URL;
        readonly state: unknown;
        readonly sameDocument: boolean;
    }, ER>;
    entries: import("./AsyncData.js").AsyncState<readonly {
        readonly id: string;
        readonly key: string;
        readonly url: URL;
        readonly state: unknown;
        readonly sameDocument: boolean;
    }[], ER>;
    transition: import("./AsyncData.js").AsyncState<Option.Option<{
        readonly type: "push" | "replace" | "reload" | "traverse";
        readonly from: {
            readonly id: string;
            readonly key: string;
            readonly url: URL;
            readonly state: unknown;
            readonly sameDocument: boolean;
        };
        readonly to: {
            readonly url: URL;
            readonly state: unknown;
            readonly sameDocument: boolean;
            readonly key?: string | undefined;
        };
        readonly info?: unknown;
    }>, ER>;
    canGoBack: import("./AsyncData.js").AsyncState<boolean, ER>;
    canGoForward: import("./AsyncData.js").AsyncState<boolean, ER>;
    navigate: (url: string | URL, options?: import("@typed/navigation/Navigation").NavigationNavigateOptions | undefined) => Promise<{
        readonly id: string;
        readonly key: string;
        readonly url: URL;
        readonly state: unknown;
        readonly sameDocument: boolean;
    }>;
    back: (options?: import("@typed/navigation/Navigation").NavigationInfoOptions | undefined) => Promise<{
        readonly id: string;
        readonly key: string;
        readonly url: URL;
        readonly state: unknown;
        readonly sameDocument: boolean;
    }>;
    forward: (options?: import("@typed/navigation/Navigation").NavigationInfoOptions | undefined) => Promise<{
        readonly id: string;
        readonly key: string;
        readonly url: URL;
        readonly state: unknown;
        readonly sameDocument: boolean;
    }>;
};

Other public imports

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

Source