Sanity Library Reference Docs
    Preparing search index...

    Interface RouterContextValue

    interface RouterContextValue {
        navigate: {
            (nextState: RouterState, options?: NavigateOptions): void;
            (options: NavigateOptions & { state?: RouterState }): void;
        };
        navigateIntent: (
            intentName: string,
            params?: IntentParameters,
            options?: NavigateBaseOptions,
        ) => void;
        navigateStickyParams: (
            params: Record<string, string>,
            options?: NavigateBaseOptions,
        ) => void;
        navigateUrl: (opts: { path: string; replace?: boolean }) => void;
        resolveIntentLink: (
            intentName: string,
            params?: IntentParameters,
            searchParams?: SearchParam[],
        ) => string;
        resolvePathFromState: (state: RouterState) => string;
        state: RouterState;
        stickyParams: Record<string, string | undefined | null>;
    }
    Index

    Properties

    navigate: {
        (nextState: RouterState, options?: NavigateOptions): void;
        (options: NavigateOptions & { state?: RouterState }): void;
    }

    Updates the router state and navigates to a new path. Allows specifying new state values and optionally merging sticky parameters.

    See RouterState and NavigateOptions

    router.navigate({stickyParams: {baz: 'qux'}})
    

    null sticky parameter value will remove the sticky parameter from the url

    router.navigate({stickyParams: {baz: 'qux'}, state: {foo: 'bar'}})
    
    router.navigate({stickyParams: {baz: 'qux'}, state: null})
    
    navigateIntent: (
        intentName: string,
        params?: IntentParameters,
        options?: NavigateBaseOptions,
    ) => void

    Navigates to the given intent. See RouterState and NavigateBaseOptions

    navigateStickyParams: (
        params: Record<string, string>,
        options?: NavigateBaseOptions,
    ) => void

    Use navigate({stickyParams: params, ...options}) instead

    navigateUrl: (opts: { path: string; replace?: boolean }) => void

    Navigates to the given URL. The function requires an object that has a path and an optional replace property.

    resolveIntentLink: (
        intentName: string,
        params?: IntentParameters,
        searchParams?: SearchParam[],
    ) => string

    Resolves the intent link for the given intent name and parameters. See IntentParameters

    resolvePathFromState: (state: RouterState) => string

    Resolves the path from the given router state. See RouterState

    When state is null, it will resolve the path from the current state and navigate to the root path.

    The current router state. See RouterState

    stickyParams: Record<string, string | undefined | null>

    The current router state. See RouterState