prefetchDNS
Hints the browser to resolve DNS for a host it will likely contact.
Syntax
prefetchDNS(href) Parameters
| Name | Type | Required | Description |
|---|---|---|---|
href | string | Yes | The origin URL whose DNS should be resolved ahead of time. |
Returns
undefined — prefetchDNS returns nothing.
Examples
import { prefetchDNS } from 'react-dom';
function App() {
prefetchDNS('https://api.example.com');
return <Main />;
}
Notes
Emits a `<link rel="dns-prefetch">` to resolve a hostname early, shaving
latency from a later request. Cheaper than preconnect; use preconnect when
you are confident a connection (including TLS) will be needed soon. React
deduplicates repeated calls for the same origin.