Prepare a host during rendering
A component's children will load fonts, scripts, images, or other resources from a known external host.
React 19+ · Function
Hints that the browser should resolve a server's IP address ahead of an expected resource request. Use it to reduce DNS delay for anticipated external resources, while remembering that the browser may ignore the hint.
Call prefetchDNS with the origin of a server that the upcoming UI is expected to contact. The browser may resolve that host early, reducing DNS lookup delay when its resources are requested. In client code it can run during rendering, effects, or event handlers; during server rendering, only calls associated with component rendering or its originating async context take effect.
prefetchDNS(href)| Name | Type | Description |
|---|---|---|
href | string | The URL of the server you want to connect to. |
Nothing.
import { prefetchDNS } from "react-dom";
function AppRoot() {
prefetchDNS("https://cdn.example.com");
return <main>Welcome</main>;
}This starts DNS resolution for the CDN while the component renders, before a child or later navigation requests resources from that host.
A component's children will load fonts, scripts, images, or other resources from a known external host.
A user action will navigate to a page that depends on another origin.
An interaction is expected to reveal UI that fetches resources from a third-party server.
preconnectpreloadpreinitpreinitModule