r/bun

▲ 7 r/bun+2 crossposts

Ran real PHP applications as TypeScript on Bun 1.3.14; migration from Node was mostly a non-event

I’ve been transpiling PHP applications to TypeScript and running the output on Bun, and I’ve now got real apps executing end to end. Sharing some notes in case they’re useful to anyone moving a Node-targeted codebase over.
Coming from Node 22, the runtime side was almost boring, most of the transpiled output just ran on Bun directly, no changes needed.

The one real snag was native code. A few C bindings (PCRE, LibXML) that worked fine on Node 22 didn’t load on Bun 1.3.14. That’s understandable: native addons are compiled against a specific runtime’s ABI/internals, so a binding built for one runtime won’t necessarily load on another. Instead of maintaining runtime-specific builds, I compiled the C bindings to WebAssembly. They’re now version-independent; no ABI coupling, so the same WASM artifact behaves the same regardless of the runtime underneath.

The thing I’m still figuring out: I’d been using Node’s cluster mode to mirror PHP-FPM’s process model (a master plus a pool of workers), and I’m still investigating how that holds up under Bun. If anyone here has run node:cluster workloads on Bun, especially anything resembling a prefork worker pool, I’d like to hear how it went and where the edges are.

reddit.com
u/Typical_Ad_6436 — 21 hours ago
▲ 3 r/bun

How do you globally link/add a local bun cli app?

I am coming from npm/pnpm world and I could do the following and have my local cli app available anywhere:

"pnpm add -g ."
"npm link ."

I've tried running:

bun add -g .
bun add -g
bun link -g

but nothing works!

reddit.com
u/Electrical-Set-6450 — 5 days ago
▲ 0 r/bun

Mochi - a new meta-framework for Svelte built on Bun

👋 Today I'm launching Mochi - a performance-focused metaframework for Svelte and an alternative to SvelteKit built on Bun. Mochi is built on an islands architecture and allows you to keep most components as performant server-side rendered code and hydrate just the components you need. This means smaller JavaScript bundles and faster performance for your users.

Try it out with bun create mochi@latest or go to https://mochi.fast to check out the docs.

reddit.com
u/khromov — 7 days ago
▲ 1 r/bun

Node.js version issues

When i try running bun dev, it throws the following error

`You are using Node.js 20.2.0. Vite requires Node.js version 20.19+ or 22.12+. Please upgrade your Node.js version.`

despite having `+ node@24.18.0` when I ran bun i.

Any help?

(I'm using bun, react, vite and bootstrap)

reddit.com
u/Snarky_Tortoise — 10 days ago
▲ 4 r/bun

Type-safe raw SQL for Bun without an ORM (codegen against your real schema)

I write Bun.sql with raw SQL and didn't want an ORM, but kept losing types — queries come back as any[] and you end up hand-writing row types that drift from the actual columns.

So I made a codegen step. You name each query:

const [user] = await sql.GetUser`
  SELECT id, email, display_name FROM users WHERE id = ${id}
`

and it generates a .d.ts mapping each name to its real result type. The way it gets the types: it runs your migration .sql files into an in-process Postgres (PGlite, no Docker) or SQLite, prepares every query against that, and reads the column types back. So it's checking your actual schema, not parsing the SQL itself.

Nullability was the annoying bit — Postgres's describe gives you types but not whether a column can be null, so I pull that from the query plan plus the catalog, with an override file for cases it can't infer.

Runtime stays plain Bun.sql, the generated file is the only artifact, and it's fast enough to run on save.

v0.1, Postgres + SQLite. Curious whether the nullability inference holds up on uglier queries than mine. Repo: https://github.com/ilbertt/bun-sqlgen

u/ilbert_luca — 13 days ago
▲ 2 r/bun

We built Appaloft with Bun: compiled binaries, embedded Web/docs assets, PGlite, and the parts that still hurt

I’m one of the people building Appaloft, an open-source deployment control plane.

We wrote up how we’re using Bun in the public Appaloft repo. The most interesting part for us was not raw speed, but the release shape Bun made possible:

- TypeScript release scripts

- bun build --compile for the CLI/server

- embedded Web console and docs assets via file imports

- embedded PGlite runtime assets for the local-first path

- separate filesystem assets in Docker

- explicit macOS/Linux/Windows release targets

The part that surprised me: --compile gives you a binary, but it does not design your runtime asset boundary. We still had to decide how /docs works, how SPA fallback differs from docs routing, how operators override embedded assets, and why Docker wants a different asset strategy than a binary archive.

Blog post:

https://www.appaloft.com/blog/we-built-appaloft-with-bun/

Curious how other Bun users are handling compiled CLIs, embedded static assets, and multi-target releases.

reddit.com
u/Independent_Yard3473 — 11 days ago