_link_ – React
_link_ – React
v19
<link>
The built-in browser <link> component lets you use external
resources such as stylesheets or annotate the document with link
metadata.
Reference
<link>
Usage
Reference
<link>
will in most cases place the corresponding DOM element in the document
head.
https://react.dev/reference/react-dom/components/link 1/10
20/02/2025, 18:27 <link> – React
Props
precedence : a string. Tells React where to rank the <link> DOM node
relative to others in the document <head> , which determines which
stylesheet can override the other. React will infer that precedence values
it discovers first are “lower” and precedence values it discovers later are
“higher”. Many style systems can work fine using a single precedence
value because style rules are atomic. Stylesheets with the same
precedence go together whether they are <link> or inline <style> tags
or loaded using preinit functions.
media : a string. Restricts the stylesheet to a certain media query.
https://react.dev/reference/react-dom/components/link 2/10
20/02/2025, 18:27 <link> – React
crossOrigin : a string. The CORS policy to use. Its possible values are
anonymous and use-credentials . It is required when as is set to
"fetch" .
React will always place the DOM element corresponding to the <link>
component within the document’s <head> , regardless of where in the React
tree it is rendered. The <head> is the only valid place for <link> to exist
within the DOM, yet it’s convenient and keeps things composable if a
component representing a specific page can render <link> components
itself.
https://react.dev/reference/react-dom/components/link 3/10
20/02/2025, 18:27 <link> – React
The component that renders <link> will suspend while the stylesheet is
loading.
If multiple components render links to the same stylesheet, React will de-
duplicate them and only put a single link into the DOM. Two links are
considered the same if they have the same href prop.
React will ignore changes to props after the link has been rendered.
(React will issue a warning in development if this happens.)
https://react.dev/reference/react-dom/components/link 4/10
20/02/2025, 18:27 <link> – React
React may leave the link in the DOM even after the component that
rendered it has been unmounted.
Usage
You can annotate the document with links to related resources such as an
icon, canonical URL, or pingback. React will place this metadata within the
document <head> regardless of where in the React tree it is rendered.
https://react.dev/reference/react-dom/components/link 5/10
20/02/2025, 18:27 <link> – React
Linking to a stylesheet
others — stylesheets with higher precedence can override those with lower
precedence.
Note
https://react.dev/reference/react-dom/components/link 6/10
20/02/2025, 18:27 <link> – React
Stylesheets can conflict with each other, and when they do, the browser goes
with the one that comes later in the document. React lets you control the
order of stylesheets with the precedence prop. In this example, three
components render stylesheets, and the ones with the same precedence are
grouped together in the <head> .
Show more
https://react.dev/reference/react-dom/components/link 7/10
20/02/2025, 18:27 <link> – React
Note the precedence values themselves are arbitrary and their naming is up
to you. React will infer that precedence values it discovers first are “lower”
and precedence values it discovers later are “higher”.
If you render the same stylesheet from multiple components, React will
place only a single <link> in the document head.
https://react.dev/reference/react-dom/components/link 8/10
20/02/2025, 18:27 <link> – React
You can use the <link> component with the itemProp prop to annotate
specific items within the document with links to related resources. In this
case, React will not place these annotations within the document <head>
but will place them like any other React component.
<section itemScope>
<h3>Annotating specific items</h3>
<link itemProp="author" href="http://example.com/" />
<p>...</p>
</section>
PREVIOUS
<textarea>
https://react.dev/reference/react-dom/components/link 9/10
20/02/2025, 18:27 <link> – React
NEXT
<meta>
uwu?
Describing the UI
Adding Interactivity
Managing State
Escape Hatches
Community More
Acknowledgements Terms
https://react.dev/reference/react-dom/components/link 10/10