All Guides

Bun Runtime Setup

Install the Bun JavaScript/TypeScript runtime. A fast alternative to Node.js.

Beginner5 min

Setup Steps

1. Install Bun:

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

2. Reload your shell:

source ~/.bashrc

3. Check version:

bun --version

4. Create a new project:

bun init

5. Install packages (npm compatible):

bun install express
bun add react react-dom

6. Run a TypeScript file:

bun run index.ts

7. Run scripts:

bun run dev
bun run build

8. Bun's built-in test runner:

bun test

9. Use as a package manager (much faster):

bun install    # instead of npm install
bun add package  # instead of npm install package

10. HTTP server (built-in):

typescript
Bun.serve({
  port: 3000,
  fetch(req) {
    return new Response("Hello Bun!")
  }
})