Bun Runtime
A fast JavaScript runtime designed as a drop-in replacement for Node.js
Bun Package Manager
Install packages up to 30x faster than npm with a global cache and workspaces
Bun Test Runner
Jest-compatible, TypeScript-first tests with snapshots, DOM, and watch mode
Bun Bundler
Bundle TypeScript, JSX, React & CSS for both browsers and servers
Get Started
Bun ships as a single, dependency-free binary and includes a runtime, package manager, test runner, and bundler. New to Bun?Install Bun
Supported platforms and all install methods.
Quickstart
Hello world in minutes with Bun.serve.
What’s Inside
- Runtime: Execute JavaScript/TypeScript files and package scripts with near-zero overhead.
- Package Manager: Fast installs, workspaces, overrides, and audits with
bun install. - Test Runner: Jest-compatible, TypeScript-first tests with snapshots, DOM, and watch mode.
- Bundler: Native bundling for JS/TS/JSX with splitting, plugins, and HTML imports.
What is Bun?
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable calledbun.
At its core is the Bun runtime, a fast JavaScript runtime designed as a drop-in replacement for Node.js. It’s written in Rust and powered by JavaScriptCore, reducing startup time and memory usage.
terminal
bun command-line tool also implements a test runner, script runner, and Node.js-compatible package manager, all significantly faster than existing tools and usable in existing Node.js projects with little to no changes.
terminal
What is a runtime?
JavaScript (or, more formally, ECMAScript) is just a specification for a programming language. Anyone can write a JavaScript engine that ingests a valid JavaScript program and executes it. The two most popular engines in use today are V8 (developed by Google) and JavaScriptCore (developed by Apple). Both are open source. But most JavaScript programs don’t run in a vacuum. They need a way to access the outside world to perform useful tasks. This is where runtimes come in. They implement additional APIs and make them available to the JavaScript programs they execute.Browsers
Browsers ship with JavaScript runtimes that implement a set of Web-specific APIs, exposed on the globalwindow object. Any JavaScript code executed by the browser can use these APIs to add interactive or dynamic behavior to the current webpage.
Node.js
Node.js is a JavaScript runtime for non-browser environments, like servers. JavaScript programs executed by Node.js have access to a set of Node.js-specific globals likeBuffer, process, and __dirname in addition to built-in modules for OS-level tasks like reading/writing files (node:fs) and networking (node:net, node:http). Node.js also implements a CommonJS-based module system and resolution algorithm that pre-dates JavaScript’s native module system.
Bun is designed as a faster, leaner, more modern replacement for Node.js.
Design goals
Bun is designed from the ground-up with today’s JavaScript ecosystem in mind.- Speed. Bun processes start 4x faster than Node.js.
- TypeScript & JSX support. You can directly execute
.jsx,.ts, and.tsxfiles; Bun’s transpiler converts these to vanilla JavaScript before execution. - ESM & CommonJS compatibility. The world is moving towards ES modules (ESM), but millions of packages on npm still require CommonJS. Bun recommends ES modules, but supports CommonJS.
- Web-standard APIs. Bun implements standard Web APIs like
fetch,WebSocket, andReadableStream. Bun is powered by the JavaScriptCore engine, which is developed by Apple for Safari, so some APIs likeHeadersandURLdirectly use Safari’s implementation. - Node.js compatibility. In addition to supporting Node-style module resolution, Bun aims for full compatibility with built-in Node.js globals (
process,Buffer) and modules (path,fs,http). This is an ongoing effort. See Node.js compatibility for the current status.