Skip to content
On this page

useNavigationContext

Definition

Composable to get navigation context from the URL.

Basic usage

ts
const { 
 navigationContext,
 routeName,
 foreignKey 
} = useNavigationContext(context);

Signature

ts
export function useNavigationContext(
  context?: Ref<SeoUrl | null>,
): UseNavigationContextReturn 

Parameters

NameTypeDescription
context
Ref<SeoUrl | null>

Return type

See UseNavigationContextReturn
ts
export type UseNavigationContextReturn = {
  /**
   * SEO URL from the navigation context
   */
  navigationContext: ComputedRef<SeoUrl | null>;
  /**
   * Route name from the navigation context
   */
  routeName: ComputedRef<RouteName | undefined>;
  /**
   * Foreign key (ID) for current navigation context
   */
  foreignKey: ComputedRef<string>;
};

Properties

NameTypeDescription
navigationContext
ComputedRef<SeoUrl | null>
SEO URL from the navigation context
routeName
ComputedRef<RouteName | undefined>
Route name from the navigation context
foreignKey
ComputedRef<string>
Foreign key (ID) for current navigation context

Usage

ts
import { useNavigationContext } from "@shopware-pwa/composables-next";

const { product } = useNavigationContext();
useNavigationContext has loaded