diff --git a/packages/react-router/src/ScriptOnce.tsx b/packages/react-router/src/ScriptOnce.tsx
index f4398deeeb..4a851a7e6a 100644
--- a/packages/react-router/src/ScriptOnce.tsx
+++ b/packages/react-router/src/ScriptOnce.tsx
@@ -1,14 +1,40 @@
+import jsesc from 'jsesc'
import { useRouter } from './useRouter'
export function ScriptOnce({
children,
log,
+ sync,
}: {
children: string
log?: boolean
+ sync?: boolean
}) {
const router = useRouter()
+ if (typeof document !== 'undefined') {
+ return null
+ }
- router.injectScript(children, { logScript: log })
- return null
+ if (!sync) {
+ router.injectScript(children, { logScript: log })
+ return null
+ }
+
+ return (
+
+ )
}
diff --git a/packages/start-client/src/Meta.tsx b/packages/start-client/src/Meta.tsx
index d33fd73e51..54e1bdb72e 100644
--- a/packages/start-client/src/Meta.tsx
+++ b/packages/start-client/src/Meta.tsx
@@ -121,8 +121,9 @@ export const useMetaElements = () => {
))}
<>
-
+