# Bun: a faster JavaScript runtime

> 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.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2026-08-07 | Topics: [JavaScript](https://flaviocopes.com/tags/js/) | Canonical: https://flaviocopes.com/bun/

Bun is a JavaScript runtime, like [Node.js](https://flaviocopes.com/nodejs/). 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:

- it's **fast** — startup and package installs are noticeably quicker than [Node.js](https://flaviocopes.com/nodejs/) and [Deno](https://flaviocopes.com/deno/)
- **TypeScript and JSX** work out of the box, no compile step
- it bundles a **package manager**, **test runner**, and **HTTP server** in one binary
- many interesting projects are built on Bun today

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:

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

If you already have Node installed, this works too:

```bash
npm install -g bun
```

Verify the install:

```bash
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:

```bash
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](https://flaviocopes.com/typescript/) on the server. Create an empty folder and add a `hello.js` file:

```js
console.log('hello')
```

Run it:

```bash
bun hello.js
```

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

Now rename `hello.js` to `hello.ts`:

```ts
console.log('hello')
```

Run it again:

```bash
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](https://flaviocopes.com/npm/) ecosystem. It reads `package.json`, installs into `node_modules`, and works with the packages you already know.

Install all dependencies in a project:

```bash
bun install
```

Add a package:

```bash
bun add express
```

Remove one:

```bash
bun remove express
```

Update a single package:

```bash
bun update express
```

Update everything:

```bash
bun update
```

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

```bash
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:

- **TypeScript and JSX** — run `.ts` and `.tsx` files directly
- **Watch mode** — `bun --watch hello.ts` restarts on file changes
- **Test runner** — `bun test` runs your test files with Jest-compatible APIs
- **HTTP server** — `Bun.serve()` for serving requests
- **SQLite** — `bun:sqlite` for embedded databases, no native addon
- **File I/O** — `Bun.file()` for reading and writing files
- **Password hashing** — `Bun.password` for secure credential storage

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`:

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

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

Run it:

```bash
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](https://bun.sh/docs/runtime/nodejs-apis) 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.
