#Dynamic breadcrumbs

10 messages · Page 1 of 1 (latest)

limpid scarab
#

I have a project route (/projects/123) which can be navigated to from 2 different routes (/projects and /customers/456). Depending on the route I have come from, the breadcrumbs in the project route should show the correct previous route.

Is there a standard for how to implement this? If I store it in a context, then what happens when someone refreshes the page? If I use localstaorage instead, there could be multiple tabs to track which can make it a bit more complicated.

I just want to make sure I am doing everything right from the start with tanstack router. I need this for the project route today but what if I need it for some other route in the future? How should I be configuring things?

slim nebula
#

which context would you use? a react context?

limpid scarab
#

That was one thought..

limpid scarab
#

How would you approach this?

slim nebula
#

not sure.
"what happens when someone refreshes the page"
also what happens if someone directly comes to that page by a link?

#

if the path the user travelled to that page is relevant, you could put it in search params

limpid scarab
#

I think in both of those 2 approaches (refresh or go to a page from a link) would have to be considered the same. The reality is that in my app people will rarely share links..

limpid scarab
#

Or actually thinking about it a bit more, I only want to retain context between page reloads. So if they close the tab and come back to the same page or if they refresh the page, it should use a default breadcrumb.

#

So in such a situation would you recommend a react context?

slim nebula