HTTP
fetch, Request, Response, and Headers are all globally available. No import is needed.
AbortController
UseAbortController 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.
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.
Hashing and passwords
Bun.hash()
Bun.hash() provides fast non-cryptographic hashing using Wyhash (default) and several other algorithms:
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:
verify() auto-detects the algorithm from the hash format (PHC for Argon2, MCF for bcrypt).
Supported APIs reference
| Category | APIs |
|---|---|
| HTTP | fetch, Request, Response, Headers, AbortController, AbortSignal |
| URLs | URL, URLSearchParams |
| Streams | ReadableStream, WritableStream, TransformStream, ByteLengthQueuingStrategy, CountQueuingStrategy |
| Blob | Blob, File, FormData |
| WebSockets | WebSocket |
| Crypto | crypto, SubtleCrypto, CryptoKey, Crypto |
| Encoding | TextEncoder, TextDecoder, TextEncoderStream, TextDecoderStream, atob, btoa |
| Timers | setTimeout, clearTimeout, setInterval, clearInterval, setImmediate, clearImmediate |
| Microtasks | queueMicrotask |
| Events | EventTarget, Event, CustomEvent, ErrorEvent, CloseEvent, MessageEvent |
| Workers | Worker, MessageChannel, MessagePort, BroadcastChannel |
| Debugging | console, performance |
| User interaction | alert, confirm, prompt (intended for interactive CLIs) |
| Compression | CompressionStream, DecompressionStream |
| Realms | ShadowRealm |
| JSON | JSON |
| Other | structuredClone, reportError, WebAssembly |