Skip to content
Discussion options

You must be logged in to vote

A router can have a handle export, this export can be anything you want, is a place Remix gives you to put things associated to a route.

Then in your components, you can use useMatches to access the currently matching routes, and this includes the handle.

So what you can do is to add a breadcrumb property to this handle.

export const handle = { breadcrumb: { label: "Something", to: "/path" } };

Then use the hook to get the matches with a handle with a breadcrumb and render the list.

const matches = useMatches().filter(match => match.handle?.breadcrumb)
return (
  <ol>
    {matches.map(match => (
      <li key={match.handle.breadcrumb.to}>
        <NavLink to={match.handle.breadcrumb.to}>{m…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ReetiMauryaCrest
Comment options

@sergiodxa
Comment options

Answer selected by ReetiMauryaCrest
@ReetiMauryaCrest
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants