mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
5.3 KiB
5.3 KiB
Bun implements a set of native APIs on the Bun global object and through a number of built-in modules. These APIs are heavily optimized and represent the canonical "Bun-native" way to implement some common functionality.
Bun strives to implement standard Web APIs wherever possible. Bun introduces new APIs primarily for server-side tasks where no standard exists, such as file I/O and starting an HTTP server. In these cases, Bun's approach still builds atop standard APIs like Blob, URL, and Request.
Bun.serve({
fetch(req: Request) {
return new Response("Success!");
},
});
Click the link in the right column to jump to the associated documentation.
{% table %}
- Topic
- APIs
- HTTP Server
Bun.serve
- Shell
$
- Bundler
Bun.build
- Child Processes
Bun.spawn,Bun.spawnSync
- TCP Sockets
Bun.listen,Bun.connect
- UDP Sockets
Bun.udpSocket
- WebSockets
new WebSocket()(client),Bun.serve(server)
- Transpiler
Bun.Transpiler
- Routing
Bun.FileSystemRouter
- Streaming HTML
HTMLRewriter
- Hashing
Bun.password,Bun.hash,Bun.CryptoHasher,Bun.sha
- SQLite
bun:sqlite
- PostgreSQL Client
Bun.SQL,Bun.sql
- Redis (Valkey) Client
Bun.RedisClient,Bun.redis
- FFI (Foreign Function Interface)
bun:ffi
- DNS
Bun.dns.lookup,Bun.dns.prefetch,Bun.dns.getCacheStats
- Testing
bun:test
- Workers
new Worker()
- Module Loaders
Bun.plugin
- Glob
Bun.Glob
- Cookies
Bun.Cookie,Bun.CookieMap
- Node-API
Node-API
import.metaimport.meta
- Utilities
Bun.version,Bun.revision,Bun.env,Bun.main
- Sleep & Timing
Bun.sleep(),Bun.sleepSync(),Bun.nanoseconds()
- Random & UUID
Bun.randomUUIDv7()
- System & Environment
Bun.which()
- Comparison & Inspection
Bun.peek(),Bun.deepEquals(),Bun.deepMatch,Bun.inspect()
- String & Text Processing
Bun.escapeHTML(),Bun.stringWidth(),Bun.indexOfLine
- URL & Path Utilities
Bun.fileURLToPath(),Bun.pathToFileURL()
- Compression
Bun.gzipSync(),Bun.gunzipSync(),Bun.deflateSync(),Bun.inflateSync(),Bun.zstdCompressSync(),Bun.zstdDecompressSync(),Bun.zstdCompress(),Bun.zstdDecompress()
- Stream Processing
Bun.readableStreamTo*(),Bun.readableStreamToBytes(),Bun.readableStreamToBlob(),Bun.readableStreamToFormData(),Bun.readableStreamToJSON(),Bun.readableStreamToArray()
- Memory & Buffer Management
Bun.ArrayBufferSink,Bun.allocUnsafe,Bun.concatArrayBuffers
- Module Resolution
Bun.resolveSync()
- Parsing & Formatting
Bun.semver,Bun.TOML.parse,Bun.color
- Low-level / Internals
Bun.mmap,Bun.gc,Bun.generateHeapSnapshot,bun:jsc
{% /table %}