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 */
6export function ScriptOnce({ children }: { children: string }) {
7 const router = useRouter()
8 if (!router.isServer) {
9 return null
10 }
11β
12 return (
13 <script
14 nonce={router.options.ssr?.nonce}
15 dangerouslySetInnerHTML={{
16 __html: children + ';document.currentScript.remove()',
17 }}
18 />
19 )
20}