@@ -214,6 +214,20 @@ function getActiveMatches(
214214
215215export const CRITICAL_CSS_DATA_ATTRIBUTE = "data-react-router-critical-css" ;
216216
217+ /**
218+ * Props for the {@link Links} component.
219+ *
220+ * @category Types
221+ */
222+ export interface LinksProps {
223+ /**
224+ * A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
225+ * attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
226+ * element
227+ */
228+ nonce ?: string | undefined ;
229+ }
230+
217231/**
218232 * Renders all the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
219233 * tags created by the route module's [`links`](../../start/framework/route-module#links)
@@ -237,10 +251,12 @@ export const CRITICAL_CSS_DATA_ATTRIBUTE = "data-react-router-critical-css";
237251 * @public
238252 * @category Components
239253 * @mode framework
254+ * @param props Props
255+ * @param {LinksProps.nonce } props.nonce n/a
240256 * @returns A collection of React elements for [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
241257 * tags
242258 */
243- export function Links ( ) : React . JSX . Element {
259+ export function Links ( { nonce } : LinksProps ) : React . JSX . Element {
244260 let { isSpaMode, manifest, routeModules, criticalCss } =
245261 useFrameworkContext ( ) ;
246262 let { errors, matches : routerMatches } = useDataRouterStateContext ( ) ;
@@ -265,13 +281,14 @@ export function Links(): React.JSX.Element {
265281 { ...{ [ CRITICAL_CSS_DATA_ATTRIBUTE ] : "" } }
266282 rel = "stylesheet"
267283 href = { criticalCss . href }
284+ nonce = { nonce }
268285 />
269286 ) : null }
270287 { keyedLinks . map ( ( { key, link } ) =>
271288 isPageLinkDescriptor ( link ) ? (
272- < PrefetchPageLinks key = { key } { ...link } />
289+ < PrefetchPageLinks key = { key } nonce = { nonce } { ...link } />
273290 ) : (
274- < link key = { key } { ...link } />
291+ < link key = { key } nonce = { nonce } { ...link } />
275292 ) ,
276293 ) }
277294 </ >
@@ -463,7 +480,7 @@ function PrefetchPageLinksImpl({
463480 { keyedPrefetchLinks . map ( ( { key, link } ) => (
464481 // these don't spread `linkProps` because they are full link descriptors
465482 // already with their own props
466- < link key = { key } { ...link } />
483+ < link key = { key } nonce = { linkProps . nonce } { ...link } />
467484 ) ) }
468485 </ >
469486 ) ;
0 commit comments