Open History to see the last commit
1import { useRouter } from './useRouter'
2β
3/**
4 * Server-only helper to emit a script tag exactly once during SSR.
5 * Appends an internal marker to signal hydration completion.
6 */
7export function ScriptOnce({ children }: { children: string }) {
8 const router = useRouter()
9 if (!router.isServer) {
10 return null
11 }
12β
13 return (
14 <script
15 nonce={router.options.ssr?.nonce}
16 className="$tsr"
17 dangerouslySetInnerHTML={{
18 __html: [children].filter(Boolean).join('\n') + ';$_TSR.c()',
19 }}
20 />
21 )
22}