Skip to main content
Bun implements many web standard APIs, making it easier to write code that works across browsers, Node.js, and Bun. These APIs follow the specifications defined by WHATWG and W3C.

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:
See fetch documentation for more details.

Streams API

Bun implements the Web Streams specification:

ReadableStream

WritableStream

TransformStream

See Streams API documentation for complete reference.

URL & URLSearchParams

Parse and manipulate URLs:

FormData

Handle form data:

Blob

Binary data handling:
Bun extends Blob with additional methods:

WebSocket

Real-time communication:
For server-side WebSocket, use Bun.serve().

Web Crypto API

Cryptographic operations:

TextEncoder / TextDecoder

Convert between strings and bytes:

Performance

Web performance APIs:

Timers

Standard timer functions:

Console

Standard console methods:
See Console API documentation for all 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