Core APIs
Bun.serve()
High-performance HTTP server with WebSocket support
Bun.file()
Fast file I/O operations with streaming support
Bun.write()
Write files, sockets, or stdout with automatic type conversion
Bun.spawn()
Launch child processes with full control over stdio
Database & Storage
bun:sqlite
Fast SQLite database with prepared statements
Bun.sql()
Unified SQL API for PostgreSQL, MySQL, and SQLite
Bun.redis()
High-performance Redis client
Bun.s3()
S3-compatible object storage client
Utilities
Bun.build()
JavaScript bundler with tree-shaking
Bun.Transpiler
Transpile TypeScript and JSX to JavaScript
bun:ffi
Call native C/C++/Rust/Zig code from JavaScript
Bun.hash()
Fast hashing functions (wyhash, xxHash, CRC32, SHA)
Performance Features
All Bun APIs are designed for speed:- Zero-copy operations: File reads and writes use efficient memory operations
- Streaming support: Handle large files without loading into memory
- Native implementations: Written in Zig for maximum performance
- Optimized allocations: Smart memory management reduces garbage collection
Example: Using Multiple APIs
Here’s an example that combines several Bun APIs:server.ts
Global Objects
Bun extends the global namespace with several utility objects:Bun
The mainBun namespace contains most APIs:
import.meta
Enhanced with Bun-specific properties:Node.js Compatibility
Bun implements most Node.js built-in modules. See Node.js Compatibility for details.Web APIs
Bun implements web standards like fetch, WebSocket, and Streams. See Web APIs for details.Next Steps
HTTP Server
Build high-performance web servers
File I/O
Read and write files efficiently
SQLite
Work with SQLite databases
All APIs
Browse all runtime APIs