Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

ScriptOnce.tsx

22 lines450 Bytes

1import { isServer } from '@tanstack/router-core/isServer'
2import { useRouter } from './useRouter'
3​
4export function ScriptOnce({
5 children,
6}: {
7 children: string
8 log?: boolean
9 sync?: boolean
10}) {
11 const router = useRouter()
12 if (!(isServer ?? router.isServer)) {
13 return null
14 }
15 return (
16 <script
17 nonce={router.options.ssr?.nonce}
18 class="$tsr"
19 innerHTML={children + ';document.currentScript.remove()'}
20 />
21 )