Modifying the Router Context with data from loader #895
Replies: 4 comments 7 replies
-
I'd be interested in this, too (for context, see #901 (comment)). Coming from |
Beta Was this translation helpful? Give feedback.
-
I think in practice the problem might get a little bit more complex. Not sure, if I'm wrong here with my route design, but consider this example:
Now, if a user would visit |
Beta Was this translation helpful? Give feedback.
-
https://tanstack.com/router/latest/docs/framework/react/guide/router-context mentions using the route contexts for the page title, but since you apparently can't alter the context from the loader, if the title comes from the loaded data, you won't be able to use a route context for it. Seems like a pretty big oversight for that use case. |
Beta Was this translation helpful? Give feedback.
-
Who would have thought that setting a Page "Title" or "Breadcrumbs" via async data could be so complicated in a router framework... The link to https://github.com/TanStack/router/blob/main/packages/react-router-server/src/client/Meta.tsx is dead now and trying to add The docs around context really need to be updated for this use case that is so common that seemly every dynamic application would need it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
is it somehow possible to add information to a Router Context from data fetched in a
loader
?For example to build a breadcrumb trail from the contexts (as in the example), it would be helpful to have informations from the fetched data. It could be useful to use the title of a blog post that was received in the
loader
, so that the title of the post can be added to the breadcrumb trail).Thanks,
Nils
Beta Was this translation helpful? Give feedback.
All reactions