Bun — All-in-One JavaScript Runtime
Fast JavaScript runtime, bundler, test runner, and package manager in one tool. Drop-in Node.js replacement. 88K+ GitHub stars.
What it is
Bun is a JavaScript runtime built from scratch in Zig with JavaScriptCore (Safari's engine) instead of V8. It bundles four tools into one binary: a runtime (replaces Node.js), a bundler (replaces Webpack/esbuild), a test runner (replaces Jest), and a package manager (replaces npm/yarn/pnpm). It supports TypeScript and JSX natively without a compilation step.
Bun targets JavaScript and TypeScript developers who want faster tooling. Its startup time, install speed, and bundling performance are significantly faster than the Node.js ecosystem equivalents.
How it saves time or tokens
Bun's package manager installs dependencies up to 25x faster than npm by using hardlinks and a global cache. The runtime starts in milliseconds. The built-in test runner eliminates Jest configuration. By combining four tools into one, Bun reduces the dependency count and configuration files in your project.
How to use
- Install Bun via curl or your package manager.
- Use it as a drop-in replacement for Node.js, npm, and Jest.
- Run TypeScript files directly without compilation.
# Install Bun
curl -fsSL https://bun.sh/install | bash
# Run a TypeScript file directly
bun run server.ts
# Install packages (faster than npm)
bun install
# Run tests
bun test
# Bundle for production
bun build ./src/index.ts --outdir ./dist
Example
// server.ts - HTTP server with Bun
const server = Bun.serve({
port: 3000,
fetch(req) {
const url = new URL(req.url);
if (url.pathname === '/api/hello') {
return Response.json({ message: 'Hello from Bun' });
}
return new Response('Not Found', { status: 404 });
},
});
console.log(`Listening on ${server.url}`);
Related on TokRepo
- AI coding tools — Tools that support Bun and TypeScript development
- Featured workflows — Popular developer tool configurations
Common pitfalls
- Not all Node.js APIs are implemented in Bun yet. Some npm packages that rely on Node-specific APIs (like child_process edge cases) may not work. Check Bun's compatibility page before migrating.
- Bun's test runner uses a different assertion API than Jest. Existing Jest test suites may need minor adjustments for expect() matchers.
- Global installs with bun install -g place binaries in a different path than npm. Make sure Bun's bin directory is in your PATH.
Frequently Asked Questions
For most projects, yes. Bun implements the majority of Node.js APIs and is compatible with most npm packages. Some edge cases around streams, worker_threads, and native addons may still require Node.js. Check Bun's Node.js compatibility table for your specific dependencies.
Benchmarks vary by workload. Bun's HTTP server handles more requests per second than Node.js in synthetic benchmarks. Package installs are up to 25x faster. Cold start time is significantly lower. Real-world performance gains depend on your application's bottlenecks.
Yes. Bun runs TypeScript files directly without a separate compilation step. It transpiles TypeScript on the fly using its built-in transpiler. This eliminates the need for ts-node, tsx, or a build step for TypeScript projects.
Yes. Bun reads package.json and node_modules like npm. You can use bun install as a drop-in replacement for npm install. The vast majority of npm packages work with Bun without modification.
Yes. Bun supports Windows, macOS, and Linux. Windows support was added after the initial launch and is now stable for most use cases. Some platform-specific edge cases may still exist.
Citations (3)
- Bun GitHub— Bun is an all-in-one JavaScript runtime and toolkit
- Bun Documentation— Bun documentation for runtime, bundler, and package manager
- Apple JavaScriptCore Docs— JavaScriptCore engine used by Bun for JavaScript execution
Related on TokRepo
Source & Thanks
Discussion
Related Assets
Moodle — Open-Source Learning Management System
The most widely used open-source learning platform, providing course management, assessments, and collaboration tools for educators and organizations worldwide.
Sylius — Headless E-Commerce Framework on Symfony
An open-source headless e-commerce platform built on Symfony and API Platform, designed for developers who need a customizable and API-first commerce solution.
Akaunting — Free Self-Hosted Accounting Software
A free, open-source online accounting application built on Laravel for small businesses and freelancers to manage invoices, expenses, and financial reports.