Breadcrumbs
Composed breadcrumbs (LAYOUT): renders the ui Breadcrumb primitive, adds a
Home item, and emits schema.org BreadcrumbList JSON-LD for SEO. Takes a
normalized trail so it stays domain-agnostic — the caller maps its own data to
{ name, href }; this package never fetches. Server-renderable so the JSON-LD
lands in the initial HTML.
import { Breadcrumbs } from "@evolve-storefront/layout/breadcrumbs";Preview
Usage
<Breadcrumbs items={trail} origin="https://shop.example" renderLink={({ href, children, className }) => ( <Link href={href} className={className}> {children} </Link> )}/>;Props
| Prop | Type | Description |
|---|---|---|
items | BreadcrumbTrailItem[] | The trail, ancestor → current. The last item renders as the current page. |
home? | BreadcrumbTrailItem | null | The leading Home item. Pass |
origin? | string | Site origin used to make JSON-LD |
renderLink? | ((props: BreadcrumbLinkRenderProps) => ReactNode) | Render an ancestor link with the app's router (e.g. Next |
resolveHref? | ((href: string) => string) | The public path of a trail |
Any other props go to the root element, like on a plain HTML element.
Examples
Long Trail
// A deep category path is the same call: the trail wraps, nothing is configured.const trail = category.ancestors.map((ancestor) => ({ name: ancestor.name, href: ancestor.href }));<Breadcrumbs items={trail} origin={origin} renderLink={renderLink} />;Single Item
// A top-level page: Home plus the current page.<Breadcrumbs items={[{ name: t("account"), href: "/account" }]} origin={origin} renderLink={renderLink} />;No Home
// The account section starts its own trail, without the leading Home item.<Breadcrumbs home={null} items={trail} origin={origin} renderLink={renderLink} />;LocalizedLocalized for crawlers too. resolveHref gives each trail href its locale prefix, so the JSON-LD item is the absolute URL a visitor actually loads — Home included, which lands on the locale root rather than /.
<Breadcrumbs items={trail} origin={origin} resolveHref={(href) => getPathname({ href, locale })}/>;Localized With Router LinksrenderLink gets the raw href. The app's router localizes it, so handing it the resolved one would prefix twice; only the JSON-LD reads resolveHref.
<Breadcrumbs items={trail} resolveHref={(href) => getPathname({ href, locale })} renderLink={(props) => <Link {...props} />}/>;
