How to change page title per route?
Back in the day we used to use React-Helmet. That seems to be unmaintained now for a while. I found this page but it doesn't explain how I can dynamically change the page title based on values on the page: https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management
Anyone done this before?
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...
8 Replies
stormy-goldOP•9mo ago
Example code:
stormy-gold•9mo ago
Hi
I am interested on your post.
thanks.
I can help you.
fair-rose•9mo ago
the only way i have found is through a useEffect
this is with out a database connected, I am going to try using it through a loader
foreign-sapphire•9mo ago
Hello! If you use react 19
You can just render a <title>{yourLoaderSata}</title>
absent-sapphire•9mo ago
with
HeadContent this is how you do it
https://github.com/TanStack/router/blob/main/e2e/react-router/basic-file-based/src/routes/posts.tsx#L9GitHub
router/e2e/react-router/basic-file-based/src/routes/posts.tsx at ma...
🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering. - TanStack/router
stormy-goldOP•9mo ago
omg amazing, using this! Thanks
stormy-gold•9mo ago
I guess this is working but there is some delay. Did you manage to fix that to be instant?
absent-sapphire•9mo ago
are you on react 19? if yes, use
HeadContent