Bun Runtime

Host Bun apps on Witchly.host — the fast all-in-one JavaScript runtime, bundler, and package manager. TypeScript and JSX out of the box.

Bun Runtime

Bun is a fast JavaScript runtime, package manager, transpiler, and bundler — all in one binary. It runs TypeScript and JSX without a build step, ships with built-in testing and HTTP servers, and is 2–4× faster than Node.js for most workloads. Witchly runs the latest Bun release.

Why Bun vs Node.js?

  • Faster startup — cold start in ~10ms.
  • TypeScript native — no tsc step, just run .ts files directly.
  • Built-in APIsBun.file(), Bun.serve(), Bun.spawn() — no need for fs, http, or child process modules.
  • Drop-in Node.js compat — most npm packages work unchanged.

Quick deploy

  1. dash.witchly.hostDeployLanguagesBun.
  2. On the Startup tab:
    • Git Repository Address — your repo URL
    • Main file — entrypoint (default index.js, but try index.ts!)
  3. Start.

Startup flow

if [[ -d .git ]] && [[ {{AUTO_UPDATE}} == "1" ]]; then git pull; fi
if [[ ! -z ${BUN_PACKAGES} ]]; then bun install ${BUN_PACKAGES}; fi
if [[ ! -z ${RMBUN_PACKAGES} ]]; then bun remove ${RMBUN_PACKAGES}; fi
bun run ${MAIN_FILE}

Variables reference

VariablePurpose
GIT_ADDRESSGit repo URL
BRANCHGit branch
USER_UPLOAD1 to skip clone
AUTO_UPDATE1 to git pull on start
MAIN_FILEEntrypoint (supports .js, .ts, .tsx)
BUN_PACKAGESExtra packages installed via bun install
RMBUN_PACKAGESPackages to remove via bun remove
USERNAME, ACCESS_TOKENPrivate repo credentials

TypeScript, zero config

Just commit a .ts file and set MAIN_FILE = index.ts:

// index.ts
const server = Bun.serve({
  port: Number(process.env.SERVER_PORT),
  fetch(req) {
    const url = new URL(req.url)
    if (url.pathname === "/") return new Response("Hello from Bun!")
    return new Response("Not found", { status: 404 })
  },
})
console.log(`Listening on :${server.port}`)

Package management

bun install is 20–30× faster than npm install. Ship a bun.lockb (binary) in your repo and the egg’s bun install step will resolve deps instantly.

For ad-hoc additions on a running server, use the Console:

bun add zod

Or set BUN_PACKAGES = zod on the Startup tab to install on each boot.

Frameworks

Bun works with:

  • Hono — ultralight HTTP framework designed for Bun
  • Elysia — Bun-native framework with end-to-end types
  • Express / Fastify — via Node.js compatibility
  • Discord.js, discord-api-types — Discord bots run great on Bun

Discord.js bot example

// index.ts
import { Client, GatewayIntentBits } from "discord.js"

const client = new Client({
  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],
})

client.on("ready", () => console.log(`Logged in as ${client.user?.tag}`))
client.on("messageCreate", (msg) => {
  if (msg.content === "!ping") msg.reply("pong")
})

client.login(process.env.DISCORD_TOKEN)

Troubleshooting

  • Package won’t install — some Node.js packages with native C addons need rebuilding; try bun install --force.
  • “Cannot find module” — commit your bun.lockb along with package.json.
  • Crashes on start — check you’re using Number(process.env.SERVER_PORT) — Bun is strict about types.

Next steps