bun is a new:
- JavaScript runtime with Web APIs like
fetch
,WebSocket
, and several more builtin. bun embeds JavaScriptCore, which tends to be faster and more memory efficient than more popular engines like V8 (though harder to embed) - JavaScript/TypeScript/JSX transpiler
- JavaScript & CSS bundler
- Task runner for package.json scripts
- npm-compatible package manager
All in one fast & easy-to-use tool. Instead of 1,000 node_modules for development, you only need bun.

bun is experimental software. Join bun’s Discord for help and have a look at things that don’t work yet.
Today, bun’s primary focus is bun.js: bun’s JavaScript runtime.
Install
Native: (macOS x64 & Silicon, Linux x64, Windows Subsystem for Linux)
curl -fsSL https://bun.sh/install | bash
Docker: (Linux x64)
docker pull jarredsumner/bun:edge docker run --rm --init --ulimit memlock=-1:-1 jarredsumner/bun:edge
If using Linux, kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1.
Table of Contents
- Install
- Using bun.js – a new JavaScript runtime environment
- Using bun as a package manager
- Using bun as a task runner
- Creating a Discord bot with Bun
- Using bun with Next.js
- Using bun with single page apps
- Using bun with TypeScript
- Not implemented yet
- Benchmarks
- Configuration
- Troubleshooting
- Reference
Bun.serve
– fast HTTP serverBun.write
– optimizing I/O- bun:sqlite (SQLite3 module)
bun:ffi
(Foreign Functions Interface)- Node-API (napi)
Bun.Transpiler
- Environment variables
- Credits
- License
- Developing bun
- vscode-zig
Using bun.js – a new JavaScript runtime environment
bun.js focuses on performance, developer experience and compatibility with the JavaScript ecosystem.
// http.ts export default { port: 3000, fetch(request: Request) { return new Response("Hello World"); }, }; // bun ./http.ts
Requests per second | OS | CPU | bun version |
---|---|---|---|
260,000 | macOS | Apple Silicon M1 Max | 0.0.76 |
160,000 | Linux | AMD Ryzen 5 3600 6-Core 2.2ghz | 0.0.76 |
bun.js prefers Web API compatibility instead of designing new APIs when possible. bun.js also implements some Node.js APIs.
- TypeScript & JSX support is builtin, powered by Bun’s JavaScript transpiler
- ESM & CommonJS modules are supported (internally, bun.js uses ESM)
- Many npm packages “just work” with bun.js (when they use few/no node APIs)
- tsconfig.json
"paths"
is natively supported, along with"exports"
in package.json fs
,path
, andprocess
from Node are partially implemented- Web APIs like
fetch
,Response
,URL
and more are builtin HTMLRewriter
makes it easy to transform HTML in bun.js- Starts 4x faster than Node (try it yourself)
.env
files automatically load intoprocess.env
andBun.env
- top level await
The runtime uses JavaScriptCore, the JavaScript engine powering WebKit and Safari. Some web APIs like Headers
and URL
directly use Safari’s implementation.
cat
clone that runs 2x faster than GNU cat for large files on Linux
// cat.js import { resolve } from "path"; import { write, stdout, file, argv } from "bun"; const path = resolve(argv.at(-1)); await write( // stdout is a Blob stdout, // file(path) returns a Blob - https://developer.mozilla.org/en-US/docs/Web/API/Blob file(path) ); // bun ./cat.js ./path-to-file
Server-side render React:
Hello from React!
The date is {dt.format(new Date())}