diff --git a/packages/embed-react/README.md b/packages/embed-react/README.md index e5ac3137..fb00bcd0 100644 --- a/packages/embed-react/README.md +++ b/packages/embed-react/README.md @@ -87,6 +87,10 @@ Pass options as props to the component. See all available options in [Vanilla JavaScript Embed Library README file](../embed/README.md#options). +#### CSP nonce support + +If the global `__webpack_nonce__` is set, its value will be used for a `nonce` attribute on the inline ` + const nonce = getNonce() + return } diff --git a/packages/embed-react/src/utils/nonce.ts b/packages/embed-react/src/utils/nonce.ts new file mode 100644 index 00000000..166777fc --- /dev/null +++ b/packages/embed-react/src/utils/nonce.ts @@ -0,0 +1,5 @@ +declare let __webpack_nonce__: string + +export default function getNonce() { + return typeof __webpack_nonce__ !== 'undefined' ? __webpack_nonce__ : null +}