| 1 | import { createContext, useContext } from "react"; |
| 2 | |
| 3 | /** |
| 4 | * The nonce the page's inline scripts carry, which its Content-Security-Policy |
| 5 | * names (lib/page-headers.ts). Given by entry.server.tsx; in the browser |
| 6 | * there is none, and none is needed: the scripts have already run. |
| 7 | */ |
| 8 | export const NonceContext = createContext<string | undefined>(undefined); |
| 9 | |
| 10 | export function useNonce(): string | undefined { |
| 11 | return useContext(NonceContext); |
| 12 | } |