diff --git a/packages/react-router/src/Asset.tsx b/packages/react-router/src/Asset.tsx index 7a81b87f173..b5d671456ad 100644 --- a/packages/react-router/src/Asset.tsx +++ b/packages/react-router/src/Asset.tsx @@ -49,8 +49,15 @@ function Script({ children?: string }) { const router = useRouter() + const dataScript = + typeof attrs?.type === 'string' && + attrs.type !== '' && + attrs.type !== 'text/javascript' && + attrs.type !== 'module' React.useEffect(() => { + if (dataScript) return + if (attrs?.src) { const normSrc = (() => { try { @@ -142,9 +149,19 @@ function Script({ } return undefined - }, [attrs, children]) + }, [attrs, children, dataScript]) if (!(isServer ?? router.isServer)) { + if (dataScript && typeof children === 'string') { + return ( +