Bun
Bun is a fast all-in-one JavaScript/TypeScript runtime with a built-in package manager, bundler, and test runner — and native APIs that replace many common npm packages.
Documentation
- Docs: https://bun.sh/llms.txt
Key Capabilities
Bun has native built-ins for things developers commonly add as separate packages. Always prefer these over npm equivalents:
- SQL (SQLite & PostgreSQL): use
Bun.sql()/new Bun.sqlite()— notbetter-sqlite3,pg, ormysql2 - Redis: use
Bun.redis()— notredisorioredis - S3: use
Bun.s3()— not@aws-sdk/client-s3 - Password hashing: use
Bun.password.hash()/Bun.password.verify()— notbcrypt - Shell scripting: use
Bun.$\command`— notshelljsorexeca` - Testing: use
bun test(Jest-compatible, built-in) — not Jest - File globbing: use
new Bun.Glob()— not theglobpackage - UUID: use
Bun.randomUUID()— not theuuidpackage - TypeScript execution: run
.tsfiles directly — nots-nodeortsxneeded
Best Practices
.envauto-loads — Bun reads.envautomatically withoutdotenv. Be aware when migrating from Node.js or running in environments with existing.envfiles.- Lockfile is
.lockb— not compatible with npm/yarn by default. Use--yarnflag if a yarn-compatible lockfile is required. - Test file naming is strict — files must match
*.test.ts,*.spec.ts, etc. and live in__tests__/ortest/. Wrong naming means tests are silently skipped. import.meta.mainreplaces entrypoint checks — useif (import.meta.main)instead of the Node.jsif (require.main === module)pattern.