From 97fadb4d0b81288ebe26708ed288faeb9e174b1a Mon Sep 17 00:00:00 2001 From: Maks Pikov Date: Sun, 5 Apr 2026 22:46:13 +0000 Subject: [PATCH 1/2] fix(react-router): preserve inline head scripts in React tree after hydration --- packages/react-router/src/Asset.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/react-router/src/Asset.tsx b/packages/react-router/src/Asset.tsx index 4de655fed8a..f4016ae2409 100644 --- a/packages/react-router/src/Asset.tsx +++ b/packages/react-router/src/Asset.tsx @@ -215,5 +215,19 @@ function Script({ } } + // For inline scripts (children, no src), keep the element in the React tree after + // hydration so React doesn't unmount the SSR-rendered script from the DOM. + // The useEffect above detects the existing element via textContent match and skips + // re-injection, so the script won't execute a second time. + if (!attrs?.src && typeof children === 'string') { + return ( +