@@ -41,7 +41,22 @@ export type CreateNextDsfrIntegrationApiParams = {
4141 doPersistDarkModePreferenceWithCookie ?: boolean ;
4242 /** Default: ()=> "fr" */
4343 useLang ?: ( ) => string ;
44- nonce ?: string ;
44+ /**
45+ * Enable Trusted Types with a custom policy name.
46+ *
47+ * `<trustedTypesPolicyName>` and `<trustedTypesPolicyName>-asap` should be set in your Content-Security-Policy header.
48+ *
49+ * For example:
50+ * ```txt
51+ * With a policy name of "react-dsfr":
52+ * Content-Security-Policy:
53+ * require-trusted-types-for 'script';
54+ * trusted-types react-dsfr react-dsfr-asap nextjs nextjs#bundler;
55+ * ```
56+ *
57+ * @see https://developer.mozilla.org/fr/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
58+ * @default "react-dsfr"
59+ */
4560 trustedTypesPolicyName ?: string ;
4661} ;
4762
@@ -91,7 +106,6 @@ export function createNextDsfrIntegrationApi(
91106 preloadFonts = [ ] ,
92107 doPersistDarkModePreferenceWithCookie = false ,
93108 useLang,
94- nonce,
95109 trustedTypesPolicyName
96110 } = params ;
97111
@@ -169,10 +183,9 @@ export function createNextDsfrIntegrationApi(
169183 />
170184 { ! isBrowser && ( //NOTE: On browser we handle this manually
171185 < >
172- < style
173- nonce = { nonce }
174- id = { rootColorSchemeStyleTagId }
175- > { `:root { color-scheme: ${ isDark ? "dark" : "light" } ; }` } </ style >
186+ < style id = { rootColorSchemeStyleTagId } > { `:root { color-scheme: ${
187+ isDark ? "dark" : "light"
188+ } ; }`} </ style >
176189 < meta
177190 name = "theme-color"
178191 content = {
@@ -184,11 +197,9 @@ export function createNextDsfrIntegrationApi(
184197 ) }
185198 { isProduction && ! isBrowser && (
186199 < script
187- nonce = { nonce }
188200 dangerouslySetInnerHTML = { {
189201 "__html" : getScriptToRunAsap ( {
190202 defaultColorScheme,
191- nonce,
192203 trustedTypesPolicyName
193204 } )
194205 } }
0 commit comments