function
dns.prefetch
hostname: string,
port?: number
): void;
Experimental API
Prefetch a hostname so that later fetch() and Bun.connect() calls can skip the DNS lookup.
@param hostname
The hostname to prefetch
@param port
The port to prefetch. Default is 443. Port helps distinguish between IPv6 vs IPv4-only connections.
import { dns } from 'bun';
dns.prefetch('example.com');
// ... something expensive
await fetch('https://example.com');