preconnect

Hints the browser to open an early connection to a server.

Since React 19 Spec ↗

Syntax

preconnect(href)

Parameters

NameTypeRequiredDescription
href string Yes The origin URL to establish a connection with ahead of time.

Returns

undefined — preconnect returns nothing.

Examples

import { preconnect } from 'react-dom';

function App() {
  preconnect('https://cdn.example.com');
  return <Gallery />;
}

Notes

Emits a `<link rel="preconnect">` so the browser performs DNS, TCP, and TLS setup before the resource is requested. More work than prefetchDNS; use it when you are confident requests to that origin are imminent. React deduplicates calls for the same origin.

See also