implementing the breadcrumbs example in docs to a typescript project
In the docs there is an example to add breadcrumbs to your layout.
https://tanstack.com/router/latest/docs/framework/react/guide/router-context#processing-accumulated-route-context
But how can i add this
getTitle function to each createFileRoute function with typescript?
getting this error now
TanStack | High Quality Open-Source Software for Web Developers
Headless, type-safe, powerful utilities for complex workflows like Data Management, Data Visualization, Charts, Tables, and UI Components.

9 Replies
genetic-orangeOP•14mo ago
the ai in the docs comes up with this solution which doesnt work
Hm found out i can use staticData for that in tanstack-router.d.ts file
but also found out the example uses the matches it has on that route. That are not really breadcrumbs right?
If im on
/ it matches only that
If im on /claims it matches only that and not /
I basically want / to be named 'dashboard' and claims to be named 'claims'
and when im on dashboard the breadcrumbs should be 'dashboard' but on claims it should be
dashboard -> claims
Is there a way to basically get the route /claims and split it and found the matches per string in the arrayrival-black•14mo ago
does this work?
genetic-orangeOP•14mo ago
That works indeed, thanks!
How do you create breadcrumbs with this? I the docs it has an example like this
But that only returns the route that are currently being rendered.
lets say i have the folder structure shown in the screenshot
/_app
index.tsx
/posts
$postId.tsx
posts.tsx
on index i want to show 'Dashboard' on posts the url is /posts and want to show 'Dashboard -> Posts' and on a single post the url is /posts/$id and the breadcrumbs should be 'Dashboard -> posts -> $id' so basically what i want is that the app folder has a layout component that automatically generates breadcrumbs for wherever you are.
on index i want to show 'Dashboard' on posts the url is /posts and want to show 'Dashboard -> Posts' and on a single post the url is /posts/$id and the breadcrumbs should be 'Dashboard -> posts -> $id' so basically what i want is that the app folder has a layout component that automatically generates breadcrumbs for wherever you are.
rival-black•14mo ago
here is an example I created for you: https://stackblitz.com/edit/tanstack-router-ic2jhk
Manuel Schiller
StackBlitz
Router Quickstart File Based Example (forked) - StackBlitz
Run official live example code for Router Quickstart File Based, created by Tanstack on StackBlitz
genetic-orangeOP•14mo ago
O wow really didnt expect you to do this, Thanks a lot! Do you mind explain a little why we need the 'route.tsx' component to set the 'Posts' title and the layout to set the 'dashboard' title instead of the actual routes?
grumpy-cyan•14mo ago
the
route.tsx will match on both index.tsx and $id.tsx, so it will show Posts on both, then on the index.tsx you dont want to show anything and on $id.tsx you want to show Posts > $id (where $id is the id of the post)
index.tsx will not match on $id.tsx, so you would end up with Posts on index.tsx and $id on $id.tsx instead of Posts > $id, that's why route.tsx is neededother-emerald•12mo ago
Hi everyone
Is this working?
rival-black•12mo ago
is it not?
correct-apricot•12mo ago
this is something that i have been struggling with too
