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

ScriptOnce.tsx

18 lines393 Bytes

1import { useRouter } from './useRouter'
2​
3export function ScriptOnce({ children }: { children: string }) {
4 const router = useRouter()
5 if (!router.isServer) {
6 return null
7 }
8​
9 return (
10 <script
11 nonce={router.options.ssr?.nonce}
12 className="$tsr"
13 dangerouslySetInnerHTML={{
14 __html: [children].filter(Boolean).join('\n') + ';$_TSR.c()',
15 }}
16 />
17 )