Skip to content
FLAVIO COPES
flaviocopes.com

Bun: a faster JavaScript runtime

By

Bun is a fast JavaScript runtime with built-in TypeScript, a package manager, and a test runner. Install it, run your first program, and explore what it offers.

~~~

Bun is a JavaScript runtime, like Node.js. But different.

It’s fast, modern, and built for a great developer experience. One binary gives you a runtime, a bundler, a package manager, and a test runner — tools that Node leaves to separate packages.

Bun wants to be a drop-in replacement for Node: in many projects you swap npm run with bun run and you’re done.

As of mid-2026, Bun is at version 1.3. The 1.3 release added a full-stack dev server, unified database clients, and a lot more Node compatibility work. This post is the first in a four-part mini-series on Bun and Hono. We’ll start with the basics.

Why Bun?

Here’s what makes Bun worth your attention:

That’s already a compelling list. My favorite reason to reach for Bun is pairing it with HTTP frameworks like Hono, which we’ll cover later in this series.

Installing Bun

Open your terminal and run:

curl -fsSL https://bun.sh/install | bash

If you already have Node installed, this works too:

npm install -g bun

Verify the install:

bun --version

You should see something like 1.3.x.

After installation you get two commands: bun and bunx. bunx runs packages without installing them globally — same idea as npx. For example:

bunx cowsay 'Hello from Bun'

For everything else, use bun. Type bun --help when you want the full list of flags.

To upgrade later, run bun upgrade.

Your first program

Bun runs JavaScript and TypeScript on the server. Create an empty folder and add a hello.js file:

console.log('hello')

Run it:

bun hello.js

Same as node hello.js, but using Bun’s runtime instead of Node.

Now rename hello.js to hello.ts:

console.log('hello')

Run it again:

bun hello.ts

It works the same way. Bun compiles TypeScript on the fly — no tsc, no extra config.

Package management

Bun interoperates with the npm ecosystem. It reads package.json, installs into node_modules, and works with the packages you already know.

Install all dependencies in a project:

bun install

Add a package:

bun add express

Remove one:

bun remove express

Update a single package:

bun update express

Update everything:

bun update

Run scripts from package.json the same way you would with npm:

bun run dev

Even if you keep running Node in production, bun install is often worth it on its own. Installs are dramatically faster than npm.

Built-in features

The thing I like most about Bun is how much ships in the box. A short tour:

Bun 1.3 also added Bun.SQL for PostgreSQL, MySQL, and SQLite, plus a built-in Redis client. That’s a lot of tooling in one download.

A tiny HTTP server

Bun.serve() takes a fetch handler, the same API shape used in Cloudflare Workers. Create server.ts:

const server = Bun.serve({
  port: 3000,
  fetch() {
    return new Response('Hello!')
  },
})

console.log(`Listening on http://localhost:${server.port}`)

Run it:

bun server.ts

Open http://localhost:3000 in your browser. One file, no Express, no build step.

Node compatibility

Bun aims for Node compatibility, but not every Node API is implemented yet — check the docs if you hit something missing.

What’s next

That covers the Bun basics: install it, run code, manage packages, and use the built-in tools.

Next in this series we’ll look at Hono, an HTTP framework that pairs beautifully with Bun.

~~~

Related posts about js: