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:
{
"name": "bun-hello-world",
"private": true,
"scripts": {
"start": "bun index.ts"
},
"dependencies": {
"picocolors": "^1.1.1"
}
}
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:
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.jsonwith astartscript. - 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:
- Pick a repository: select the repo you just pushed.
- Configure the deployment:
- Branch: the branch you pushed to.
- Region: US East (NYC).
- Review and create: Primcloud auto-provisions the app's primary
*.primcloud.appsubdomain 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.jsonandbun.lockat 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-lockfileruns against the lockfile to produce an exactnode_modulestree. - Build scripts. If the app defines
heroku-prebuild,heroku-build/build, orheroku-postbuildinpackage.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, thestartscript becomes thewebprocess (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 installand 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 thewebformation, and the sample passesprocess.env.PORTtoBun.serve.
Where to go next#
- Deploying a different Bun app: Bun on Primcloud for detection, build behavior, and how the default
webprocess is chosen. - Pinning a Bun version: Runtime versions.
- Authenticating a private registry, or using Bun to build assets for a Ruby, PHP, or Rust app: Package managers.
- Adding a build step or installing OS-level libraries: Customizing the build.
- Something breaking: Troubleshooting Bun.