Fetch API
Bun implements the complete Fetch API for making HTTP requests:fetch()
Global function for HTTP requests:Request
HTTP request representation:Response
HTTP response representation:Headers
HTTP headers management:Streams API
Bun implements the Web Streams specification:ReadableStream
WritableStream
TransformStream
URL & URLSearchParams
Parse and manipulate URLs:FormData
Handle form data:Blob
Binary data handling:WebSocket
Real-time communication:Web Crypto API
Cryptographic operations:TextEncoder / TextDecoder
Convert between strings and bytes:Performance
Web performance APIs:Timers
Standard timer functions:Console
Standard console methods:Event APIs
EventTarget
AbortController / AbortSignal
Cancel operations:Additional Web APIs
Bun implements many other web standards:- atob() / btoa(): Base64 encoding/decoding
- structuredClone(): Deep copy objects
- queueMicrotask(): Schedule microtask
- MessageChannel / MessagePort: Message passing
- BroadcastChannel: Cross-context messaging
Browser Compatibility
Bun’s web APIs are designed to be compatible with browser implementations. Code using these APIs can often run unchanged in browsers. However, some APIs have server-specific behavior:- fetch() supports
file://URLs and Unix domain sockets - WebSocket has server-side implementation in Bun.serve()
- Performance APIs may have different precision
Next Steps
fetch()
Learn about HTTP requests with fetch
Streams
Work with Web Streams API
WebSocket
Real-time communication
Bun APIs
Explore Bun-specific APIs