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 aHeaders instance:
Reading response bodies
Streaming response bodies
Useresponse.body (a ReadableStream) or an async iterator to process large responses without buffering them entirely in memory:
Streaming request bodies
Send aReadableStream 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: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:Additional protocols
Beyond HTTP and HTTPS, Bun’sfetch supports several other URL schemes:
S3 — s3://
S3 — s3://
File — file://
File — file://
Data — data:
Data — data:
Blob — blob:
Blob — blob:
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:Debugging
Setverbose: true to print request and response headers to the terminal:
"curl" for more detailed output mimicking curl -v.