export const Route = createFileRoute('/test')({
component: RouteComponent,
head: () => ({
scripts: [
{
async: true,
src: `https://www.googletagmanager.com/gtag/js?id=ID`,
},
{
// this is missing on hydrated HTML
children: `window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'ID');`,
},
],
}),
});
Which project does this relate to?
Router
Describe the bug
Children code in scripts (
<script>window.dataLayer...</script>) disappears after hydration on first page visit, reappears if navigating first to another page.Your Example Website or App
https://stackblitz.com/edit/github-zpekad3w-lxs8xvjn?file=src%2Froutes%2Ftest%2Froute.tsx
Steps to Reproduce the Bug or Issue
npm run build)node .output/server/index.mjs<script>window.dataLayer...</script>is missing.Expected behavior
<script>window.dataLayer...</script>should not disappear after hydrationScreenshots or Videos
20260405-1621-11.0158618.mp4
Platform
Additional context
No response