Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called bun.
At its core is the Bun runtime, a fast JavaScript runtime designed as a drop-in replacement for Node.js. It's written in Zig and powered by JavaScriptCore under the hood, dramatically reducing startup times and memory usage.
bun run index.tsx # TS and JSX supported out-of-the-boxThe bun command-line tool also implements a
test runner, script runner, and Node.js-compatible package manager.
Instead of 1,000 node_modules for development, you only need bun.
Bun's built-in tools are significantly faster than existing options and
usable in existing Node.js projects with little to no changes.
bun test # run tests
bun run start # run the `start` script in `package.json`
bun install <pkg> # install a package
bunx cowsay 'Hello, world!' # execute a packageBun supports Linux (x64 & arm64), macOS (x64 & Apple Silicon), and Windows (x64 & arm64).
Linux users — Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1.
x64 users — if you see "illegal instruction" or similar errors, check our CPU requirements
# with install script (recommended)
curl -fsSL https://bun.com/install | bash
# on windows
powershell -c "irm bun.sh/install.ps1 | iex"
# with npm
npm install -g bun
# with Homebrew
brew tap oven-sh/bun
brew install bun
# with Docker
docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bunTo upgrade to the latest version of Bun, run:
bun upgradeBun automatically releases a canary build on every commit to main. To upgrade to the latest canary build, run:
bun upgrade --canary-
Intro
-
Templating
-
Runtime
-
Package manager
-
Bundler
-
Test runner
-
Package runner
-
API
- HTTP server (
Bun.serve) - HTTP routing
- HTTP error handling
- HTTP metrics
- WebSockets
- Workers
- Binary data
- Streams
- File I/O (
Bun.file) - Archive (tar)
- SQLite (
bun:sqlite) - PostgreSQL (
Bun.sql) - Redis (
Bun.redis) - S3 Client (
Bun.s3) - FileSystemRouter
- TCP sockets
- UDP sockets
- Globals
- Child processes (spawn)
- Cron (
Bun.cron) - WebView
- Transpiler (
Bun.Transpiler) - Hashing
- Colors (
Bun.color) - Console
- FFI (
bun:ffi) - C Compiler (
bun:fficc) - HTMLRewriter
- Cookies (
Bun.Cookie) - CSRF (
Bun.CSRF) - Secrets (
Bun.secrets) - YAML (
Bun.YAML) - TOML (
Bun.TOML) - JSON5
- JSONL
- Markdown
- Image processing
- Utils
- Node-API
- Glob (
Bun.Glob) - Semver (
Bun.semver) - DNS
- fetch API extensions
- HTTP server (
-
Deployment
-
Binary
- Convert a Blob to a string
- Convert a Buffer to a blob
- Convert a Blob to a DataView
- Convert a Buffer to a string
- Convert a Blob to a ReadableStream
- Convert a Blob to a Uint8Array
- Convert a DataView to a string
- Convert a Uint8Array to a Blob
- Convert a Blob to an ArrayBuffer
- Convert an ArrayBuffer to a Blob
- Convert a Buffer to a Uint8Array
- Convert a Uint8Array to a Buffer
- Convert a Uint8Array to a string
- Convert a Buffer to an ArrayBuffer
- Convert an ArrayBuffer to a Buffer
- Convert an ArrayBuffer to a string
- Convert a Uint8Array to a DataView
- Convert a Buffer to a ReadableStream
- Convert a Uint8Array to an ArrayBuffer
- Convert an ArrayBuffer to a Uint8Array
- Convert an ArrayBuffer to an array of numbers
- Convert a Uint8Array to a ReadableStream
-
Ecosystem
- Use React and JSX
- Use Gel with Bun
- Use Prisma with Bun
- Use Prisma Postgres with Bun
- Add Sentry to a Bun app
- Create a Discord bot
- Run Bun as a daemon with PM2
- Use Drizzle ORM with Bun
- Use Upstash Redis with Bun
- Build an app with Nuxt and Bun
- Build an app with Qwik and Bun
- Build an app with Astro and Bun
- Build an app with Remix and Bun
- Build a frontend using Vite and Bun
- Build an app with Next.js and Bun
- Run Bun as a daemon with systemd
- Build an HTTP server using Hono and Bun
- Build an app with SvelteKit and Bun
- Build an app with SolidStart and Bun
- Build an app with TanStack Start and Bun
- Build an HTTP server using Elysia and Bun
- Build an HTTP server using StricJS and Bun
- Containerize a Bun application with Docker
- Build an HTTP server using Express and Bun
- Use Neon Postgres through Drizzle ORM
- Server-side render (SSR) a React component
- Read and write data to MongoDB using Mongoose and Bun
- Use Neon's Serverless Postgres with Bun
-
HTMLRewriter
-
HTTP
- Hot reload an HTTP server
- Common HTTP server usage
- Write a simple HTTP server
- Configure TLS on an HTTP server
- Send an HTTP request using fetch
- Proxy HTTP requests using fetch()
- Start a cluster of HTTP servers
- Stream a file as an HTTP Response
- fetch with unix domain sockets in Bun
- Upload files via HTTP using FormData
- Streaming HTTP Server with Async Iterators
- Streaming HTTP Server with Node.js Streams
- Server-Sent Events (SSE) with Bun
-
Install
- Add a dependency
- Add a Git dependency
- Add a peer dependency
- Add a trusted dependency
- Add a development dependency
- Add a tarball dependency
- Add an optional dependency
- Generate a yarn-compatible lockfile
- Configuring a monorepo using workspaces
- Install a package under a different name
- Install dependencies with Bun in GitHub Actions
- Using bun install with Artifactory
- Configure git to diff Bun's lockb lockfile
- Override the default npm registry for bun install
- Using bun install with an Azure Artifacts npm registry
- Migrate from npm install to bun install
- Configure a private registry for an organization scope with bun install
-
Process
-
Read file
-
Runtime
- Delete files
- Run a Shell Command
- Import a JSON file
- Import a TOML file
- Import a YAML file
- Import a JSON5 file
- Set a time zone in Bun
- Set environment variables
- Re-map import paths
- Delete directories
- Read environment variables
- Import a HTML file as text
- Install and run Bun in GitHub Actions
- Debugging Bun with the web debugger
- Install TypeScript declarations for Bun
- Debugging Bun with the VS Code extension
- Inspect memory usage using V8 heap snapshots
- Define and replace static globals & constants
- Build-time constants with --define
- Codesign a single-file JavaScript executable on macOS
-
Streams
- Convert a ReadableStream to JSON
- Convert a ReadableStream to a Blob
- Convert a ReadableStream to a Buffer
- Convert a ReadableStream to a string
- Convert a ReadableStream to a Uint8Array
- Convert a ReadableStream to an array of chunks
- Convert a Node.js Readable to JSON
- Convert a ReadableStream to an ArrayBuffer
- Convert a Node.js Readable to a Blob
- Convert a Node.js Readable to a string
- Convert a Node.js Readable to an Uint8Array
- Convert a Node.js Readable to an ArrayBuffer
-
Test
- Spy on methods in
bun test - Bail early with the Bun test runner
- Mock functions in
bun test - Run tests in watch mode with Bun
- Use snapshot testing in
bun test - Skip tests with the Bun test runner
- Using Testing Library with Bun
- Update snapshots in
bun test - Run your tests with the Bun test runner
- Set the system time in Bun's test runner
- Set a per-test timeout with the Bun test runner
- Migrate from Jest to Bun's test runner
- Write browser DOM tests with Bun and happy-dom
- Mark a test as a "todo" with the Bun test runner
- Re-run tests multiple times with the Bun test runner
- Generate code coverage reports with the Bun test runner
- import, require, and test Svelte components with bun test
- Set a code coverage threshold with the Bun test runner
- Selectively run tests concurrently with glob patterns
- Spy on methods in
-
Util
- Generate a UUID
- Hash a password
- Escape an HTML string
- Get the current Bun version
- Upgrade Bun to the latest version
- Encode and decode base64 strings
- Compress and decompress data with gzip
- Sleep for a fixed number of milliseconds
- Detect when code is executed with Bun
- Check if two objects are deeply equal
- Compress and decompress data with DEFLATE
- Get the absolute path to the current entrypoint
- Get the directory of the current file
- Check if the current file is the entrypoint
- Get the file name of the current file
- Convert a file URL to an absolute path
- Convert an absolute path to a file URL
- Get the absolute path of the current file
- Get the path to an executable bin file
-
WebSocket
-
Write file
- Delete a file
- Write to stdout
- Write a file to stdout
- Write a Blob to a file
- Write a string to a file
- Append content to a file
- Write a file incrementally
- Write a Response to a file
- Copy a file to another location
- Write a ReadableStream to a file
from https://github.com/oven-sh/bun
------
A curated list of awesome things related to Bun
A curated list of awesome things related to Bun
Bun is an incredibly fast JavaScript runtime, bundler, transpiler and package manager – all in one.
- Essentials
- Articles
- Boilerplates
- Extensions
- Videos
- Tools
- Community
- Contributing
- License
- Exploring Bun
- Scaffolding your bun project
- Bun Tutorial – Getting Started Guide With Examples
- Create a react app with bun
- Let's create a next.js app with bun
- Bun: A Complete Overhaul of the JavaScript Ecosystem
- Server-Side Rendering (SSR) With Bun and React
- Extro - open source browser extension starter kit
- Bun on Railway - Starter
- Bun on Dev Containers & GitHub Codespaces
- Create Bun Boilerplates
- React Bun Template for Gitpod
- React-Typescript template
- Bun Lib Starter
- tRPC + Bun
- remix-bun
- Bun Template for Gitpod
- Nixpacks Bun web server
- sveltekit-bun-template
- react-nostalgia-boilerplate
- Bun OpenAI Whisper Microservice with Docker
- DBest Stack
- 🐵 Xmonkey Userscript: Bun + TypeScript Boilerplate
- Elysia - Fast, and friendly Bun web framework.
- Hono - Ultrafast web framework for Cloudflare Workers, Deno, and Bun. Fast, but not only fast.
- Vixeny - A fast, pure functional web framework for Bun and Deno.
- Grace - An innovative, type-safe and easy-to-use API framework.
- Primate - Expressive, minimal and extensible web framework.
- NBit - A zero-dependency, strongly-typed web framework for Bun, Node and Cloudflare workers.
- GraphQL Yoga - A fast, fully featured GraphQL Framework that runs on Bun, Cloudflare Workers, Deno, and any JS environment.
- Gamepadzilla A plug-and-play gamepad frontend framework for HTML5 mobile games, supporting both virtual and physical joysticks. No scripting required.
- BunWork - Simple, Fast and Minimalist Backend Framework with No Pain
- Brisa A full-stack web framework with Server Actions and Web Components with JSX + signals
- Mantou - A Fullstack React Framework with auto generated documentation.
- Blade — Build instant web apps with React.
- @stricjs/utils - A set of blazingly fast, general-purpose web utilities.
- Hattip - Set of JavaScript packages for building HTTP server applications, with Bun support.
- Siopao - Minimal routing library. Based on Radix Tree.
- Fluxify - A neat little library powered by Bun for building apis.
- GraphQL Mesh - Gateway that takes any source API and exposes GraphQL. Runs on Bun, Cloudflare Workers, Deno, and any JS environment.
- bun-types - Typescript with Bun.
- bun-fs-router-plugin - Bundler plugin to enable filesystem based routing at build time
- bun-utilities - Bindings for useful functions for bun.
- bun-livereload - Automatically reload any imports.
- bun-html-live-reload - Automatically reload html when Bun server hot reloads.
- bun-wifi-name - Get current wifi name in Bun.
- serve-static-bun - Serve static files using Bun.serve or Bao.js.
- bun-promptx - Terminal prompt library based on bubbles via bun:ffi.
- blipgloss - Style definitions for nice terminal layouts 👄.
- Orama - 🌌 Fast, in-memory, typo-tolerant, full-text search engine written in TypeScript.
- bnx - zx inspired shell for Bun/Node.
- bun-aws-lambda - Hacky attempt to get bun to run on AWS Lambda
- postgres-bun - fast postgres bindings for bun runtime (libpq ffi)
- prerender-macro - Bun plugin to prerender JSX components using a kind of macro
- type-explorer - Runtime type inspection and schema generation for JS/TS.
- svelte-adapter-bun - Adapter for SvelteKit apps that generates a standalone Bun server.
- kysely-bun-sqlite - Kysely with SQLite, running on Bun.
- fable-bun - Fable bindings for Bun.sh.
- duckdb - 🦆 fast duckdb bindings for bun runtime.
[EN] 🇬🇧
- JavaScript just got way faster - Fireship
- What is Bun
- Install Bun JS In Windows - Faster JavaScript
- Install and Run Bun JS In Real Server
- How to create and run Next.js App on Bun JavaScript Runtime
- How to create and run React App on Bun JavaScript Runtime
- New JS runtimes Deno & Bun - Shawn Swyx Wang
[ES] 🇪🇸
- bun.new - Instant Bun playground in browser.
- Bum - A fast Bun version manager written in Rust.
- sublime-bun - Bun binary files viewer and other Bun-related stuff for Sublime Text editor.
- Shumai - A delicious new outlook on command line argument handling with Bun.
- asdf-bun - asdf version manager plugin for installing Bun.
- setup-bun - Set up your GitHub Actions workflow with a specific version of Bun.
- action-setup-bun - Setup GitHub Actions workflow with a specific version of Bun.
- bun-discord-bot - Interaction Discord bot written in JS and TS using Bun runtime environment.
- bun-discord-bot(serverless) - Official serverless discord bot for bun discord server.
- bunbot - Native cross-platform GUI automation for the Bun runtime. Supports Mac and Windows for now.
- Discall - A async functional discord API wrapper written in bun.
- bun-doc - A procedural documentation and website generator written in Bun.
- VS Code Bun extension - VS Code extension to execute JavaScript .js file or TypeScript .ts file by Bun.
- Discord
- Bun tagged NPM packages
- Benchmarks
- Framework benchmarks - Comparing Bun HTTP frameworks.
- Bun HTTP Framework Benchmark - Compare throughput benchmark from various Bun HTTP frameworks.
- sveltekit-adapter-bun
from https://github.com/oven-sh/awesome-bun
No comments:
Post a Comment