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:
{
"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 it to a repo you've connected to Primcloud:
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#
Hit Import Git Repository on the applications list, then:
- Select the repo you just pushed.
- Configure the branch you pushed to and a region.
- 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.jsonandbun.lockat 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-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, dev dependencies and packages your lockfile doesn't list are removed from
node_modules. - Start. With no
Procfile, thestartscript becomes thewebprocess (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 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.