|
I’ve been using Bun-first stacks in a few monorepos and ended up extracting two small packages that might save others some glue code. Both are MIT, ESM-only, and avoid Node shims. — trpc-bun (Bun-native tRPC adapter: HTTP + WebSocket)
What: Run tRPC on Bun.serve with first-class HTTP and WS.
How: HTTP via a fetch adapter + server.upgrade; WS via Bun’s websocket handler; one-liner server composer; optional reconnect broadcast.
Reqs: Bun ≥ 1.3.0, @trpc/server ≥ 11.6.0, TS ≥ 5.
Repo: https://github.com/lacion/trpc-bun Highlights:
• Uses only public tRPC server APIs (v11)
• createTrpcBunFetchAdapter, createTrpcBunWebSocketAdapter, configureTrpcBunServer
• Connection params over WS, subscriptions, mutations, error shaping
• Duplicate-id protection, graceful stop/disconnect
• bun test + GitHub Actions CI — kysely-bun-sql (Kysely Postgres dialect backed by Bun SQL)
What: Tiny, dependency-free Kysely dialect/driver using Bun’s native SQL client.
How: Pooled SQL under the hood (reserve()/release()), Kysely’s Postgres adapter + query compiler.
Reqs: Bun ≥ 1.1.31, Kysely ≥ 0.28, TS ≥ 5.
Repo: https://github.com/lacion/kysely-bun-sql Highlights:
• Bun-native PostgreSQL via new SQL() or env auto-detection
• Pooling, prepared statements, parameter binding via Bun SQL
• Full Kysely integration (adapter, query compiler, introspector)
• Transactions and savepoints through Kysely
• No runtime deps, ESM only I’ve been running both in real projects; publishing them to get more eyes on edge cases. Would love feedback on correctness, ergonomics, and Bun version quirks. Issues/PRs welcome. Thanks for taking a look. |