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[]>;
  /**
   * Build breadcrumbs dynamically for a category by fetching them from the API
   *
   * @param {operations["readBreadcrumb get /breadcrumb/{id}"]["response"]} breadcrumbs
   */
  buildDynamicBreadcrumbs(
    breadcrumbs: operations["readBreadcrumb get /breadcrumb/{id}"]["response"],
  ): Promise<void>;
  /**
   * Add a breadcrumb to the breadcrumbs list
   *
   * @param {Breadcrumb} breadcrumb
   */
  pushBreadcrumb(breadcrumb: Breadcrumb): void;
};

source code