prefetch

Bun

Symbol

dns.prefetch

function prefetch(hostname: string): void

Experimental API

Prefetch a hostname.

This will be used by fetch() and Bun.connect() to avoid DNS lookups.

@param hostname

The hostname to prefetch

import { dns } from 'bun';
dns.prefetch('example.com');
// ... something expensive
await fetch('https://example.com');