Bun Runtime
TriFrost ships with first-class support for Bun, the fast, all-in-one JavaScript runtime. Itβs a great choice for modern apps that prioritize speed, native TypeScript, and tight feedback loops.
This guide covers the key things to know when running TriFrost on Bun, including setup specifics, compatibility notes, and best practices.
Why Bun?
Bun brings:
- β‘ Blazing-fast startup and execution
- π Built-in support for TypeScript, JSX, and module resolution
- π¦ An integrated package manager (
bun install) - π Super-fast watch mode (
bun --watch)
TriFrost taps directly into these benefits with:
- Native JSX + atomic hydration support
- Auto-detection
- Built-in Bun adapters (no polyfills needed)
- Instant dev feedback with
bun run dev
Installation & Hello World
You can scaffold a Bun-powered TriFrost project in seconds:
bun create trifrost@latestThen choose:
- Runtime:
Bun - Optional modules: Cache, RateLimiter, Styling, etc.
Or create it manually:
bun add @trifrost/coreimport {App} from '@trifrost/core';
new App()
.get('/', ctx => ctx.text('Hello from Bun!'))
.boot();π Learn more about the Creation CLI
Bun-Specific Details
Automatic detection
TriFrost detects Bun automatically, no runtime config needed.
TypeScript & JSX Support
Bun supports .ts and .tsx natively. Your tsconfig.json should be set up with:
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"jsx": "react-jsx",
"jsxImportSource": "@trifrost/core",
...
}
}π You donβt need tsc to run your app, just bun run.
Scripts & Watch Mode
The CLI sets up this in your package.json:
{
"scripts": {
"dev": "bun run --watch ./src/index.ts",
"build": "rm -rf ./dist && bun build ./src/index.ts --outdir ./dist"
}
}You get instant reloading with:
bun run devContainer Support (Optional)
TriFrost also supports Podman for containerized Bun development. If enabled during setup, it will:
- Scaffold a
Containerfilewithoven/bunbase image - Configure
compose.ymlwith your app on a custom network
podman-compose upThis is useful if you want consistent environments across dev/prod.
Dev Tips
- Use
.envfiles for local config - Add
TRIFROST_DEV=truein.envto enable dev-mode tracing
π Also see: Dev Mode | Environment Config
Gotchas & Recommendations
- β Make sure you're on Bun v1.1.10+, earlier versions may lack needed stability for streaming, file serving, etc.
- π Avoid mixing CommonJS + ESM packages unless you know what you're doing, bun expects full ESM.
- β
Prefer
bun installovernpm install, bun manages its own lockfile (bun.lockb). - π§ͺ You can write tests with
bun test, but for deeper testing we recommendvitestif needed (it also keeps your test logic agnostic in case you ever want to switch to lets say NodeJS). - β
JSX hydration is fully supported out-of-the-box with TriFrost's
client.cssandclient.scriptif configured.
π§ Generated Project Structure
A default Bun project will include:
/src
βββ index.ts β Entry point
βββ routes/ β Route handlers
βββ components/ β Layouts and JSX
βββ css.ts β Styling system
βββ script.ts β Scripting system
βββ types.ts β Context/Env/Router types
/public
βββ logo.svg
βββ favicon.ico
Containerfile (optional)
compose.yml (optional)
eslint.config.mjs
tsconfig.json
package.json
bun.lockb
.env
.prettierrcAll routes and assets fully scaffolded by the Creation CLI, no config needed.
TLDR
- Bun is a great choice for speed and dev velocity
- TriFrost has zero-config support for Bunβs runtime and APIs
- You can opt into container support if desired
- Everything is TypeScript and JSX native