T
TanStack7mo ago
quickest-silver

Looking for a Meta module like Remix/ReactRouter7 for dynamic titles and such

Is Start going to include some kind of Meta function so that we can dynamically set page titles dynamically, either with something set statically in the route or dynamically with vars from a database call? I found soneone else here wrote their own hook which is great. But I'm hoping for a native function. TanStack Router has some bits under https://tanstack.com/router/latest/docs/framework/react/guide/router-context#processing-accumulated-route-context but I'm not sure how to wire it into what Start does for the head section.
Router Context | TanStack Router React Docs
TanStack Router's router context is a very powerful tool that can be used for dependency injection among many other things. Aptly named, the router context is passed through the router and down throug...
6 Replies
exotic-emerald
exotic-emerald7mo ago
it's called <HeadContent> (new name as of v1.105.0 )
robust-apricot
robust-apricot7mo ago
Are you just pointing out the rename? Same functionality as before?
exotic-emerald
exotic-emerald7mo ago
almost it now handles scripts in <head> separately from body scripts
quickest-silver
quickest-silverOP7mo ago
The documentation does not tell me how to define the title of my route in the route file. It's all focused on the root route.
exotic-emerald
exotic-emerald7mo ago
right now you would need to add this to the route:
head: () => ({
meta: [{title: 'your title'}]
}),
head: () => ({
meta: [{title: 'your title'}]
}),
we need to improve title handling so its more explicit
plain-purple
plain-purple7mo ago
@Manuel Schiller is it not rather head: () => ({title: "your title"})? https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management#managing-the-document-head But either way, I couldn't make it work yet in my SPA
Document Head Management | TanStack Router React Docs
Document head management is the process of managing the head, title, meta, link, and script tags of a document and TanStack Router provides a robust way to manage the document head for full-stack appl...

Did you find this page helpful?