Docs / Programming & Development / How to Build and Deploy a Bun Application

How to Build and Deploy a Bun Application

By Admin · Mar 1, 2026 · Updated Apr 23, 2026 · 29 views · 2 min read

What Is Bun?

Bun is an all-in-one JavaScript runtime, bundler, and package manager designed for speed. It is compatible with most Node.js APIs and npm packages while offering significantly faster startup times and installs. Running Bun on your Breeze is a great choice for performance-sensitive applications.

Prerequisites

  • A Breeze running Ubuntu 22.04 or later
  • Nginx installed for reverse proxying

Step 1: Install Bun

curl -fsSL https://bun.sh/install | bash
source ~/.bashrc
bun --version

Step 2: Create a Project

mkdir /var/www/bun-app && cd /var/www/bun-app
bun init

Create index.ts:

const server = Bun.serve({
  port: 3000,
  fetch(req) {
    return new Response("Hello from Bun!");
  },
});
console.log(`Listening on ${server.port}`);

Step 3: Run with PM2

sudo npm install -g pm2
pm2 start --interpreter ~/.bun/bin/bun index.ts --name "bun-app"
pm2 save && pm2 startup

Step 4: Nginx Reverse Proxy

server {
    listen 80;
    server_name yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
sudo ln -s /etc/nginx/sites-available/bun /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

Using Bun as a Package Manager

Bun replaces npm for installs: bun install runs up to 25x faster. Use bun add express to add packages. Existing package.json and node_modules are fully compatible.

Was this article helpful?