T
TanStack•4mo ago
adverse-sapphire

Head data loading => What about streaming head data using deferred external data

Hello, I have a dynamic route to load a post, and I would like to know if it is possible to use data that is loaded in the loader to integrate them in the head? For example, I'd like to be able to define the title and canonical URLs in the head using dynamically loaded data. Another question: in my __root I have two links to change the language. I'd like these links to correspond to the current location of my page, using dynamic parameters associated with the post that's currently visible. How can I do this? I appreciate your help in advance. Thank you
My route : /posts/$postId In $postId route I load my post with all needed data for localization, metadata etc
4 Replies
xenial-black
xenial-black•4mo ago
you can access loaderData in head is this what you need? about the link question, please provide a complete minimal example by forking one of the existing router examples on stackblitz to showcase your scenario
adverse-sapphire
adverse-sapphireOP•4mo ago
Thanks ! it was exactly what I was looking for. Why the documentation didn't mention anything about that ? Maybe you should add more detail I'll do that Hello again. In the same context, what about head and deferred data using streaming ? I'm trying to get deferred data in the head function. is there anyway to achieve this ? (since next 15.2 it's called "streaming metadata") https://nextjs.org/docs/app/api-reference/functions/generate-metadata#streaming-metadata Can I do the same in TanStack Router ?
xenial-black
xenial-black•4mo ago
no streaming support yet for meta but we could think about adding this
adverse-sapphire
adverse-sapphireOP•4mo ago
Ok, thanks 🙂

Did you find this page helpful?