Skip to main content
Bun implements the WHATWG fetch standard with extensions tailored for server-side use. The fetch global is available everywhere without imports.

GET request


Common HTTP methods


Request headers

Pass headers as a plain object or a Headers instance:

Reading response bodies


Streaming response bodies

Use response.body (a ReadableStream) or an async iterator to process large responses without buffering them entirely in memory:

Streaming request bodies

Send a ReadableStream as a request body. Bun streams it directly to the network without buffering the entire body in memory:

File uploads with FormData


Timeouts and cancellation

Timeout with AbortSignal.timeout()

Manual cancellation with AbortController


Proxy support

Route requests through an HTTP or HTTPS proxy:
Send custom headers to the proxy (for example, Proxy-Authorization):
You cannot use proxy and unix together in the same request.

Unix socket support

Fetch from a server listening on a Unix domain socket:

TLS options

Use a client certificate for mutual TLS authentication:
Disable certificate verification (development only):
Setting rejectUnauthorized: false disables TLS validation entirely. Never use this in production.
Custom server identity check:

Additional protocols

Beyond HTTP and HTTPS, Bun’s fetch supports several other URL schemes:

Performance

DNS prefetching

Warm up the DNS cache before you need to make a request:

Preconnect

Start the TCP/TLS handshake before the request is issued:

Connection pooling

Bun automatically pools and reuses connections to the same host (HTTP keep-alive). To opt out for a single request:
The default maximum number of simultaneous connections is 256. Raise it with:

Debugging

Set verbose: true to print request and response headers to the terminal:
Pass "curl" for more detailed output mimicking curl -v.