Skip to content
12 linesCodeBlameRaw
1import { 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 */
8export const NonceContext = createContext<string | undefined>(undefined);
9
10export function useNonce(): string | undefined {
11 return useContext(NonceContext);
12}