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<Schemas["SeoUrl"] | null>,
): UseNavigationContextReturn 

Parameters ​

NameTypeDescription
context
Ref< | null>

Return type ​

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

Properties ​

NameTypeDescription
navigationContext
ComputedRef< | null>
SEO URL from the navigation context
routeName
ComputedRef< | 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