--- title: useNonce description: The `useNonce` hook returns the [content security policy](/docs/custom-storefronts/hydrogen/content-security-policy) nonce. Use the hook to manually add a nonce to third party scripts. The `Script` component automatically does this for you. Note, the nonce should never be available in the client, and should always return undefined in the browser. api_version: 2023-07 api_name: hydrogen source_url: html: https://shopify.dev/docs/api/hydrogen/2023-07/hooks/usenonce md: https://shopify.dev/docs/api/hydrogen/2023-07/hooks/usenonce.md --- # use​Noncehook The `useNonce` hook returns the [content security policy](https://shopify.dev/docs/custom-storefronts/hydrogen/content-security-policy) nonce. Use the hook to manually add a nonce to third party scripts. The `Script` component automatically does this for you. Note, the nonce should never be available in the client, and should always return undefined in the browser. ## use​Nonce() ### Examples * #### Example code ##### Description I am the default example ##### JavaScript ```jsx import { Links, LiveReload, Meta, Outlet, Scripts, ScrollRestoration, } from '@remix-run/react'; import {useNonce} from '@shopify/hydrogen'; export default function App() { const nonce = useNonce(); return ( ); } ``` ##### TypeScript ```tsx import { Links, LiveReload, Meta, Outlet, Scripts, ScrollRestoration, } from '@remix-run/react'; import {useNonce} from '@shopify/hydrogen'; export default function App() { const nonce = useNonce(); return ( ); } ``` ## Related [![](https://shopify.dev/images/icons/32/pickaxe-1.png)![](https://shopify.dev/images/icons/32/pickaxe-1-dark.png)](https://shopify.dev/docs/api/hydrogen/2023-07/utilities/createcontentsecuritypolicy) [createContentSecurityPolicy](https://shopify.dev/docs/api/hydrogen/2023-07/utilities/createcontentsecuritypolicy) [![](https://shopify.dev/images/icons/32/pickaxe-1.png)![](https://shopify.dev/images/icons/32/pickaxe-1-dark.png)](https://shopify.dev/docs/api/hydrogen/2023-07/components/script) [Script](https://shopify.dev/docs/api/hydrogen/2023-07/components/script)