Bun is a JavaScript runtime to replace Node.js. It is built based on Apple's JS JavaScriptCore.
Features
Bun offers a lot out of the box
- Package management
- Test runner
- Transpilation of TS / JS
- Bundling into executables
- SQL, Redis and S3 SDKs built-in
- Parsers and util for HTML, YAML, TOML and JSON
- Cron jobs
- Foreign-function interface for writing and running code written in Zig, C/C++ and Rust
Install Bun
With brew:
brew tap oven-sh/bun
brew install bun
Installing a specific version with brew: brew install bun@1.1.38
Bun's CLI replaces Node and NPM both:
Creating a project: bun init
Adding dependencies: bun add react react-dom
My bun sandbox: /sandbox/bun-sandbox
Bunx package runner
Like NPX, Bun also has a package runner called Bun x, available in the terminal as bunx.
Building a Vite app
For more on Vite, see Vite
Bun with Elysia
bun create elysia app
Bun with Astro
Bun and React.js
Bun is great for working with #React