Skip to content
Shopware

useBreadcrumbs

useBreadcrumbs

Composable for breadcrumbs management. Read the guide.

Types

ts
export function useBreadcrumbs(
  newBreadcrumbs?: Breadcrumb[],
): UseBreadcrumbsReturn

source code

ts
export type Breadcrumb =
  | {
      name: string;
      path?: string;
    }
  | Schemas["Breadcrumb"];

source code

ts
export type UseBreadcrumbsReturn = {
  /**
   * Clear breadcrumbs store
   */
  clearBreadcrumbs(): void;
  /**
   * List of breadcrumbs
   */
  breadcrumbs: ComputedRef<Breadcrumb[]>;
  /**
   * Get category breadcrumbs from the API
   *
   * @param {string} categoryId
   * @returns
   */
  getCategoryBreadcrumbs: (
    categoryId: string,
  ) => Promise<operations["readBreadcrumb get /breadcrumb/{id}"]["response"]>;
  /**
   * Build breadcrumbs dynamically for a category by fetching them from the API
   *
   * @param {string} categoryId
   */
  buildDynamicBreadcrumbs(categoryId: string): Promise<void>;
};

source code