Docs menu

Getting started with Bun

Deploy a minimal Bun web app to Primcloud end-to-end from a repo you create, in about five minutes.

On this page

This guide walks through deploying a small Bun app to Primcloud. You'll create a minimal app, push it to a repo, import it, watch the build, and reach the deployed app at a *.primcloud.app URL. Takes about five minutes.

Before you start#

You'll need:

  • A Primcloud account. Standard accounts are free to create; compute is metered by the minute once you deploy, from around $5/mo for the smallest app.
  • A git provider connected to your account with access to at least one repo.
  • Bun installed locally, to install the sample's dependency and write its lockfile.

The sample app#

Create a directory with two files:

package.json
{
  "name": "bun-hello-world",
  "private": true,
  "scripts": {
    "start": "bun index.ts"
  },
  "dependencies": {
    "picocolors": "^1.1.1"
  }
}
index.ts
import pc from "picocolors";

const server = Bun.serve({
  port: Number(process.env.PORT ?? 3000),
  fetch() {
    return new Response("Hello World!");
  },
});

console.log(pc.green(`Listening on port ${server.port}`));

Install the dependency so Bun writes bun.lock, then commit and push to a repo your connected provider can see:

Terminal
bun install
git init
git add package.json bun.lock index.ts
git commit -m "hello world"

The repo now holds the files a Bun app on Primcloud relies on:

  • A package.json with a start script.
  • A bun.lock, the lockfile that marks the repo as a Bun app and pins a reproducible dependency graph.

Leave node_modules out of the repo.

1. Create the application#

From the Primcloud dashboard, hit Import Git Repository on the applications list. The import wizard walks you through three quick steps:

  1. Pick a repository: select the repo you just pushed.
  2. Configure the deployment:
    • Branch: the branch you pushed to.
    • Region: US East (NYC).
  3. Review and create: Primcloud auto-provisions the app's primary *.primcloud.app subdomain on the production environment.

2. Deploy#

The first deployment kicks off automatically when the app is created. Watch it stream in the Deployments tab:

  • Detection. Primcloud sees the package.json and bun.lock at the repo root and picks the Bun toolchain.
  • Bun install. The sample doesn't pin a Bun version, so Primcloud's default is installed. The build log names the version it resolved.
  • Dependencies. bun install --frozen-lockfile runs against the lockfile to produce an exact node_modules tree.
  • Build scripts. If the app defines heroku-prebuild, heroku-build / build, or heroku-postbuild in package.json, they run in that order. The sample doesn't ship any of these, so this step is skipped.
  • Prune. After the build, packages your lockfile doesn't list are removed from node_modules. Dev dependencies stay installed.
  • Release. With no Procfile, the start script becomes the web process (bun run start), and Primcloud starts it on the pod formation.

When the deployment status flips to Release Succeeded, the app is live.

3. Reach the app#

The application dashboard shows the assigned *.primcloud.app URL in the header. Click it, and the app answers Hello World!.

If it doesn't come up:

  • Deployments: the build log has the raw output from bun install and any build scripts.
  • Logs: runtime output from your app streams there, including any startup errors.
  • Confirm the app binds to the port in $PORT. Primcloud sets this env var on the web formation, and the sample passes process.env.PORT to Bun.serve.

Where to go next#