Bun 1.3 shipped something no other JavaScript runtime has attempted: built-in clients for PostgreSQL, MySQL, SQLite, and Redis. Zero npm dependencies, zero native bindings, zero config files. You write Bun.sql or Bun.redis and it works.
If you've been running pg, mysql2, and ioredis for years, the real question isn't whether this is cool, it's whether these built-ins are actually ready to replace your existing setup.
What changes with Bun.SQL
vs pg (PostgreSQL)
No more manual .connect(), no more .rows unwrapping, and transactions collapse into a single call:
await sql.begin(async (tx) => {
await tx`UPDATE accounts SET balance = balance - ${amount} WHERE id = ${fromAccount}`;
await tx`UPDATE accounts SET balance = balance + ${amount} WHERE id = ${toAccount}`;
});
// Auto-commits on success, auto-rolls back on exception
vs mysql2 (MySQL)
The same tagged template syntax works for both Postgres and MySQL. Switch databases and your query code doesn't change, only the connection config does.
vs ioredis
Options objects replace positional flag strings:
// ioredis
await redis.set(key, val, 'EX', 60, 'NX');
// Bun.redis
await redis.set(key, val, { ex: 60, nx: true });
Pub/sub moves from event emitters to async iterators, which fits more naturally with for await...of.
The honest performance take
Bun's own benchmarks claim up to 7.9x throughput over ioredis. In synthetic tight-loop tests, sure. In a real app with network latency and business logic between calls, expect something closer to 10 to 30 percent improvement. Real, but not a reason to migrate on its own.
What's actually missing
- No Redis Cluster support yet
- No Lua scripting on Bun.redis
- No Sentinel support
- MySQL mode lacks prepared statement caching
- If you need to run on Node.js too, the npm packages remain your only option
Should you migrate now?
If you're starting fresh on Bun with simple CRUD and basic Redis usage, probably yes. If you depend on Redis Cluster, Lua scripts, or an ORM without Bun.SQL adapter support (Prisma and TypeORM don't have one yet), wait.
Full side-by-side code comparisons, a complete migration decision framework, and a dev/prod database-switching pattern are in the full post:
🔗 https://devencyclopedia.com/blog/bun-sql-redis-clients
If you want to convert your existing pg/mysql2/ioredis code automatically, I also built a Bun Snippet Converter that runs entirely client-side.
Top comments (0)