Basic Usage
components/breadcrumbs.tsx
Data Structure
API
useBreadcrumb
React hook for generating breadcrumbs:getBreadcrumbItems
Direct function for server-side or non-React usage:getBreadcrumbItemsFromPath
Generate breadcrumbs from a pre-computed path:Options
Examples
Include Root
Add the root node to breadcrumbs:Include Current Page
Add the current page as the last item:Include Separators
Include separator nodes from page tree:Styled Components
With Icons
Structured Data
Add JSON-LD breadcrumb schema for SEO:Responsive Design
Integration with Search
Breadcrumbs are automatically included in search results:Path Search
Manually search for a page path in the tree:- Returns full path from root to target page
- Returns
nullif page not found - Normalizes URLs for comparison
- Works with nested folder structures
Folder Behavior
Breadcrumbs handle folders intelligently:Root Folders
Root folders (root: true) are excluded by default:
Best Practices
- Include Root: Always include root with URL for better navigation
- Current Page: Include current page for completeness and accessibility
- Structured Data: Add JSON-LD schema for SEO benefits
- Mobile: Truncate breadcrumbs on mobile to save space
- Icons: Use chevrons or slashes for clear separation
- Hover States: Add hover styles for interactive breadcrumbs
- ARIA: Use
aria-label="Breadcrumb"for accessibility - Last Item: Style the last item differently (non-link or bold)