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

Deploy a small Bun app to Primcloud: create a minimal app, push it to a repo, import it, watch the build, and open the app at its *.primcloud.app URL. It takes about five minutes.

Before you start#

You'll need:

  • A Primcloud account. Standard accounts have no monthly fee; compute is metered by the minute once you deploy, from around $5/mo for the smallest app.
  • A git provider connected to your Primcloud account; see Source Control.
  • 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 it to a repo you've connected to Primcloud:

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#

Hit Import Git Repository on the applications list, then:

  1. Select the repo you just pushed.
  2. Configure the branch you pushed to and a region.
  3. Verify the commit and hit Import.

2. Deploy#

The first deployment starts as soon as the app is created, and its build log streams live:

  • 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 the newest available Bun 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, dev dependencies and packages your lockfile doesn't list are removed from node_modules.
  • Start. With no Procfile, the start script becomes the web process (bun run start), and Primcloud starts it.

When the deployment's Rollout phase shows Complete, 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#