npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

breadcrumb-core

v3.0.1

Published

Zero-config breadcrumbs from your route config. Progressive loading, custom matchers, i18n, collapsible overflow, and adapters for React Router, Next.js, and TanStack Router.

Readme

breadcrumb-core 🧭

Zero-config breadcrumbs from your route config — progressive loading, custom matchers, i18n, collapsible overflow, SEO JSON-LD, and adapters for React Router, Next.js, and TanStack Router.

npm version npm downloads license CI TypeScript

🌐 Live Demo · npm · GitHub · Changelog


Installation

npm install breadcrumb-core

Quick Start

// main.tsx / app/layout.tsx
import { BreadcrumbProvider } from 'breadcrumb-core/react-router' // or /next, /tanstack-router
import { routes } from './routes'

<BreadcrumbProvider routes={routes}>
  <App />
</BreadcrumbProvider>

// Any page — zero breadcrumb code
import { AutoBreadcrumb } from 'breadcrumb-core/react-router'
<AutoBreadcrumb separator="/" injectJsonLd syncDocumentTitle appName="MyApp" />
// → Home / Products / iPhone 15 / Reviews

Route Config (v3)

import type { RouteConfig } from 'breadcrumb-core'

const routes: RouteConfig[] = [
  { path: '/', label: 'Home' },

  // Standard named param
  { path: '/products', label: 'Products' },
  { path: '/products/:id', label: async ({ params }) => fetchName(params.id), cacheTtl: 60_000 },

  // Wildcard
  { path: '/docs/*', label: 'Docs' },

  // Optional param
  { path: '/shop/:category?', label: ({ params }) => params.category ?? 'All' },

  // RegExp matcher with named groups (v3)
  { path: /^\/p\/(?<id>\d+)$/, label: ({ params }) => `Product ${params.id}` },

  // Function matcher (v3)
  {
    path: (pathname) => {
      const m = pathname.match(/^\/items-(\w+)$/)
      return m ? { slug: m[1] } : null
    },
    label: ({ params }) => `Item: ${params.slug}`,
  },

  // With icon, hidden, onMatch
  { path: '/settings', label: 'Settings', icon: <GearIcon />, onMatch: ({ pathname }) => analytics.page(pathname) },
  { path: '/app', label: 'App', hidden: true },
]

v3 Features

Progressive per-item loading (v3)

Static labels render instantly. Async labels each show a skeleton independently and swap in as they resolve:

// Default behaviour — nothing to change
<AutoBreadcrumb />

// Custom per-item skeleton
<AutoBreadcrumb
  renderItemSkeleton={(item) => (
    <span className="my-skeleton" style={{ width: item.isLast ? 100 : 60 }} />
  )}
/>

i18n locale-prefix stripping (v3)

// Handles /en/products/42 and /fr/products/42 with the same route definitions
<BreadcrumbProvider routes={routes} locales={['en', 'fr', 'de', 'ja']}>

// Read detected locale anywhere
import { useBreadcrumbLocale } from 'breadcrumb-core/react-router'
const locale = useBreadcrumbLocale() // → 'fr'

Label transform (v3)

// Post-process every label globally
<BreadcrumbProvider
  routes={routes}
  transformLabel={(label) => t(label)} // e.g. i18next
/>

Collapsible overflow (v3)

import { CollapsibleBreadcrumb } from 'breadcrumb-core/ui'

// Home / ••• / Reviews  — click ••• to expand inline
<CollapsibleBreadcrumb collapseAt={4} theme="light" />

Active route hook (v3)

import { useActiveRoute } from 'breadcrumb-core/react-router'
const active = useActiveRoute()
// → { path, label, params, isLast, route } | null

Cache invalidation after mutations

import { invalidateLabelCache } from 'breadcrumb-core'
await renameProduct(id, newName)
invalidateLabelCache(productRoute, { id })

Analytics

<BreadcrumbProvider
  routes={routes}
  onNavigate={(items, pathname) =>
    analytics.page(pathname, { trail: items.map(i => i.label).join(' > ') })
  }
/>

API Reference

<BreadcrumbProvider>

| Prop | Type | Default | Description | |------|------|---------|-------------| | routes | RouteConfig[] | required | Route definitions | | children | ReactNode | required | App content | | onNavigate | (items, pathname) => void | — | Called after each navigation | | maxHistory | number | 20 | Max snapshots for useBreadcrumbHistory() | | locales | string[] | — | v3 i18n locale prefixes to strip | | transformLabel | (label, item) => string | — | v3 Global label transformer |

<AutoBreadcrumb>

| Prop | Type | Default | Description | |------|------|---------|-------------| | separator | ReactNode | "/" | Between items | | maxItems | number | — | Collapse middle with (static) | | showHome | boolean | true | Include root item | | className | string | — | CSS class on <nav> | | syncDocumentTitle | boolean | false | Auto-update document.title | | appName | string | — | Appended to synced title | | injectJsonLd | boolean | false | Inject Schema.org JSON-LD | | baseUrl | string | "" | Base URL for JSON-LD | | renderItem | (item, isLast) => ReactNode | — | Custom item renderer | | renderItemSkeleton | (item) => ReactNode | — | v3 Per-item skeleton | | renderSkeleton | () => ReactNode | — | Full-replacement skeleton (legacy) | | progressiveLoading | boolean | true | v3 Per-item async rendering | | ariaLabel | string | "breadcrumb" | aria-label on <nav> | | onItemClick | (item) => boolean \| void | — | Intercept item clicks |

RouteConfig

| Field | Type | Description | |-------|------|-------------| | path | string \| RegExp \| fn | v3 string, RegExp with groups, or (pathname) => params \| null | | label | string \| fn | Static or async. fn receives { params, pathname } | | icon | ReactNode | Icon before label | | hidden | boolean | Skip in breadcrumb | | cacheTtl | number | Cache TTL in ms | | onMatch | fn | Called when segment is matched |

Hooks

| Hook | Returns | Description | |------|---------|-------------| | useBreadcrumb() | BreadcrumbItem[] | Current items (with isLoading per item) | | useBreadcrumbLoading() | boolean | True while any label is resolving | | useBreadcrumbHistory() | BreadcrumbItem[][] | Navigation snapshots | | useActiveRoute() | BreadcrumbItem \| null | v3 Last (current) item | | useBreadcrumbLocale() | string \| null | v3 Detected locale prefix |

Core utilities

import {
  matchRoute,
  buildBreadcrumbs,
  buildBreadcrumbsProgressive, // v3
  generateJsonLd,
  clearLabelCache,
  invalidateLabelCache,
  stripLocalePrefix,            // v3
  withLocalePrefix,             // v3
} from 'breadcrumb-core'

UI components

import {
  StyledBreadcrumb,        // themes: light | dark | minimal | pill
  CollapsibleBreadcrumb,   // v3: expandable ••• overflow
  BreadcrumbSkeleton,      // full-row shimmer
} from 'breadcrumb-core/ui'

Migration

  • v1 → v3: No breaking changes. Drop in v3 and get progressive loading automatically.
  • v2 → v3: No breaking changes. All v2 features still work unchanged.
  • See CHANGELOG.md for the full additions per version.

License

MIT © virendra2902