Skip to main content
Bun implements Web-standard APIs wherever possible instead of inventing new ones. This means code written for the browser (or other modern runtimes like Deno and Cloudflare Workers) often runs in Bun without changes. Browser-only APIs like the DOM or History API have no meaning in a server context and are not included. Everything else that makes sense server-side is implemented.

HTTP

fetch, Request, Response, and Headers are all globally available. No import is needed.

AbortController

Use AbortController to cancel in-flight fetch requests.

URLs

URL and URLSearchParams are globally available and work identically to their browser counterparts.

Streams

Bun fully implements the WHATWG Streams API.

ReadableStream

A stream of data you can read from, chunk by chunk.

WritableStream

A stream of data you can write to.

TransformStream

A writable stream that produces a readable stream after transformation.

Queuing strategies

ByteLengthQueuingStrategy and CountQueuingStrategy for backpressure control.

Blob and File

Blob represents raw binary data. File extends Blob with a name and lastModified.

FormData

FormData is fully implemented, including file uploads.

WebSocket

WebSocket is available globally for connecting to WebSocket servers.
Bun also has a high-performance server-side WebSocket API via Bun.serve. See the WebSockets page.

Web Crypto

The Web Crypto API (crypto, SubtleCrypto, CryptoKey) is available globally.

Encoding

TextEncoder and TextDecoder convert between strings and binary data. atob and btoa handle base64.

Timers

All standard timer functions are globally available.

Console

console matches the browser and Node.js APIs.

Performance

performance is available globally for measuring timing.

Events

The full event system is implemented.

Workers

Worker (Web Workers API) is available for running JavaScript on background threads.
For a full guide on workers and inter-thread communication, see the Workers page.

Hashing and passwords

Bun.hash()

Bun.hash() provides fast non-cryptographic hashing using Wyhash (default) and several other algorithms:
All variants accept string, ArrayBuffer, TypedArray, or DataView. An optional seed can be passed as the second argument.

Bun.password

Bun.password provides secure password hashing using Argon2 (default) or bcrypt:
Configure the algorithm and its parameters:
verify() auto-detects the algorithm from the hash format (PHC for Argon2, MCF for bcrypt).

Supported APIs reference