ScriptsApr 3, 2026·2 min read

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.

TL;DR
Bun combines JavaScript runtime, bundler, test runner, and package manager in one fast tool. Drop-in Node.js replacement.
§01

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.

§02

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.

§03

How to use

  1. Install Bun via curl or your package manager.
  2. Use it as a drop-in replacement for Node.js, npm, and Jest.
  3. 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
§04

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}`);
§05

Related on TokRepo

§06

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

Can Bun replace Node.js completely?+

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.

How much faster is Bun than Node.js?+

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.

Does Bun support TypeScript natively?+

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.

Can I use Bun with existing npm packages?+

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.

Does Bun work on Windows?+

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)
🙏

Source & Thanks

Created by Oven. Licensed under MIT.

bun — ⭐ 88,700+

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets