How to make server request on each route change
Hello,
I was wondering if it is possible to make server requests on each route change? While I was testing out Tanstack router + Vite, I hit a minor edge-case with with my SSR setup.
In short I have an index.html template, which setups the <head> with some metatags for example
<title>{{pageTitle}}</title>
. The <head></head> is then read from the index.html and passed to the client through the Router Context. Then I run a transformerFn, to the stream to replace the {{pageTitle}} with one coming from route's staticData.
Everything works fine when doing a page load, via url or page refresh, but when using client-side navigation, the head metatags are not updated, as the server is not called.
P.S.:
I saw there is undocumented <Meta/> feature in the tanstack.com repo, but from what I can see the tanstack.com website, has the exact same issue, of metatags not updating during client-side navigation.1 Reply
xenial-blackOP•17mo ago
Nvm. After some sleep, I managed to solve the issue in a hacky way.