stephane.bio
  • Invest
  • Build
  • Write
  • Think
Ketchup

oven-sh/bun: Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one

URL
https://github.com/oven-sh/bun
image

Bun

image
image
image

Documentation • Discord • Issues • Roadmap

Read the docs →

What is Bun?

Bun is under active development. Use it to speed up your development workflows or run simpler production code in resource-constrained environments like serverless functions. We're working on more complete Node.js compatibility and integration with existing frameworks. Join the Discord and watch the GitHub repository to keep tabs on future releases.

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-box

The 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 package

Install

Bun supports Linux (x64 & arm64), macOS (x64 & Apple Silicon) and Windows (x64).

Linux users — Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1.

# with install script (recommended)
curl -fsSL https://bun.sh/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/bun

Upgrade

To upgrade to the latest version of Bun, run:

bun upgrade

Bun automatically releases a canary build on every commit to main. To upgrade to the latest canary build, run:

bun upgrade --canary

View canary build

Quick links

    1. Intro

    2. What is Bun?
    3. Installation
    4. Quickstart
    5. TypeScript
    1. Templating

    2. bun init
    3. bun create
    1. Runtime

    2. bun run
    3. File types
    4. TypeScript
    5. JSX
    6. Environment variables
    7. Bun APIs
    8. Web APIs
    9. Node.js compatibility
    10. Single-file executable
    11. Plugins
    12. Watch mode
    13. Module resolution
    14. Auto-install
    15. bunfig.toml
    16. Debugger
    17. Framework API
    1. Package manager

    2. bun install
    3. bun add
    4. bun remove
    5. bun update
    6. bun link
    7. bun pm
    8. Global cache
    9. Workspaces
    10. Lifecycle scripts
    11. Filter
    12. Lockfile
    13. Scopes and registries
    14. Overrides and resolutions
    1. Bundler

    2. Bun.build
    3. Loaders
    4. Plugins
    5. Macros
    6. vs esbuild
    1. Test runner

    2. bun test
    3. Writing tests
    4. Watch mode
    5. Lifecycle hooks
    6. Mocks
    7. Snapshots
    8. Dates and times
    9. DOM testing
    10. Code coverage
    1. Package runner

    2. bunx
    1. API

    2. HTTP server
    3. WebSockets
    4. Workers
    5. Binary data
    6. Streams
    7. File I/O
    8. import.meta
    9. SQLite
    10. FileSystemRouter
    11. TCP sockets
    12. UDP sockets
    13. Globals
    14. $ Shell
    15. Child processes
    16. Transpiler
    17. Hashing
    18. Console
    19. FFI
    20. HTMLRewriter
    21. Testing
    22. Utils
    23. Node-API
    24. Glob
    25. Semver
    1. Project

    2. Roadmap
    3. Benchmarking
    4. Contributing
    5. Building Windows
    6. License

Guides

    1. Binary

    2. Convert a Blob to a DataView
    3. Convert a Blob to a ReadableStream
    4. Convert a Blob to a string
    5. Convert a Blob to a Uint8Array
    6. Convert a Blob to an ArrayBuffer
    7. Convert a Buffer to a blob
    8. Convert a Buffer to a ReadableStream
    9. Convert a Buffer to a string
    10. Convert a Buffer to a Uint8Array
    11. Convert a Buffer to an ArrayBuffer
    12. Convert a DataView to a string
    13. Convert a Uint8Array to a Blob
    14. Convert a Uint8Array to a Buffer
    15. Convert a Uint8Array to a DataView
    16. Convert a Uint8Array to a ReadableStream
    17. Convert a Uint8Array to a string
    18. Convert a Uint8Array to an ArrayBuffer
    19. Convert an ArrayBuffer to a Blob
    20. Convert an ArrayBuffer to a Buffer
    21. Convert an ArrayBuffer to a string
    22. Convert an ArrayBuffer to a Uint8Array
    23. Convert an ArrayBuffer to an array of numbers
    1. Ecosystem

    2. Build a frontend using Vite and Bun
    3. Build an app with Astro and Bun
    4. Build an app with Next.js and Bun
    5. Build an app with Nuxt and Bun
    6. Build an app with Qwik and Bun
    7. Build an app with Remix and Bun
    8. Build an app with SolidStart and Bun
    9. Build an app with SvelteKit and Bun
    10. Build an HTTP server using Elysia and Bun
    11. Build an HTTP server using Express and Bun
    12. Build an HTTP server using Hono and Bun
    13. Build an HTTP server using StricJS and Bun
    14. Containerize a Bun application with Docker
    15. Create a Discord bot
    16. Deploy a Bun application on Render
    17. Read and write data to MongoDB using Mongoose and Bun
    18. Run Bun as a daemon with PM2
    19. Run Bun as a daemon with systemd
    20. Server-side render (SSR) a React component
    21. Use Drizzle ORM with Bun
    22. Use EdgeDB with Bun
    23. Use Neon's Serverless Postgres with Bun
    24. Use Prisma with Bun
    25. Use React and JSX
    26. Add Sentry to a Bun app
    1. HTTP

    2. Common HTTP server usage
    3. Configure TLS on an HTTP server
    4. fetch with unix domain sockets in Bun
    5. Hot reload an HTTP server
    6. Proxy HTTP requests using fetch()
    7. Send an HTTP request using fetch
    8. Start a cluster of HTTP servers
    9. Stream a file as an HTTP Response
    10. Streaming HTTP Server with Async Iterators
    11. Streaming HTTP Server with Node.js Streams
    12. Upload files via HTTP using FormData
    13. Write a simple HTTP server
    1. Install

    2. Add a dependency
    3. Add a development dependency
    4. Add a Git dependency
    5. Add a peer dependency
    6. Add a tarball dependency
    7. Add a trusted dependency
    8. Add an optional dependency
    9. Configure a private registry for an organization scope with bun install
    10. Configure git to diff Bun's lockb lockfile
    11. Configuring a monorepo using workspaces
    12. Generate a human-readable lockfile
    13. Install a package under a different name
    14. Install dependencies with Bun in GitHub Actions
    15. Override the default npm registry for bun install
    16. Using bun install with an Azure Artifacts npm registry
    17. Using bun install with Artifactory
    1. Process

    2. Get the process uptime in nanoseconds
    3. Listen for CTRL+C
    4. Listen to OS signals
    5. Parse command-line arguments
    6. Read from stdin
    7. Read stderr from a child process
    8. Read stdout from a child process
    9. Spawn a child process
    10. Spawn a child process and communicate using IPC
    1. Read file

    2. Check if a file exists
    3. Get the MIME type of a file
    4. Read a file as a ReadableStream
    5. Read a file as a string
    6. Read a file to a Buffer
    7. Read a file to a Uint8Array
    8. Read a file to an ArrayBuffer
    9. Read a JSON file
    10. Watch a directory for changes
    1. Runtime

    2. Debugging Bun with the VS Code extension
    3. Debugging Bun with the web debugger
    4. Define and replace static globals & constants
    5. Import a JSON file
    6. Import a TOML file
    7. Import HTML file as text
    8. Install and run Bun in GitHub Actions
    9. Install TypeScript declarations for Bun
    10. Re-map import paths
    11. Read environment variables
    12. Run a Shell Command
    13. Set a time zone in Bun
    14. Set environment variables
    1. Streams

    2. Convert a Node.js Readable to a Blob
    3. Convert a Node.js Readable to a string
    4. Convert a Node.js Readable to an ArrayBuffer
    5. Convert a Node.js Readable to JSON
    6. Convert a ReadableStream to a Blob
    7. Convert a ReadableStream to a Buffer
    8. Convert a ReadableStream to a string
    9. Convert a ReadableStream to a Uint8Array
    10. Convert a ReadableStream to an array of chunks
    11. Convert a ReadableStream to an ArrayBuffer
    12. Convert a ReadableStream to JSON
    1. Test

    2. Bail early with the Bun test runner
    3. Generate code coverage reports with the Bun test runner
    4. Mark a test as a "todo" with the Bun test runner
    5. Migrate from Jest to Bun's test runner
    6. Mock functions in bun test
    7. Re-run tests multiple times with the Bun test runner
    8. Run tests in watch mode with Bun
    9. Run your tests with the Bun test runner
    10. Set a code coverage threshold with the Bun test runner
    11. Set a per-test timeout with the Bun test runner
    12. Set the system time in Bun's test runner
    13. Skip tests with the Bun test runner
    14. Spy on methods in bun test
    15. Update snapshots in bun test
    16. Use snapshot testing in bun test
    17. Write browser DOM tests with Bun and happy-dom
    1. Util

    2. Check if the current file is the entrypoint
    3. Check if two objects are deeply equal
    4. Compress and decompress data with DEFLATE
    5. Compress and decompress data with gzip
    6. Convert a file URL to an absolute path
    7. Convert an absolute path to a file URL
    8. Detect when code is executed with Bun
    9. Encode and decode base64 strings
    10. Escape an HTML string
    11. Get the absolute path of the current file
    12. Get the absolute path to the current entrypoint
    13. Get the current Bun version
    14. Get the directory of the current file
    15. Get the file name of the current file
    16. Get the path to an executable bin file
    17. Hash a password
    18. Sleep for a fixed number of milliseconds
    1. WebSocket

    2. Build a publish-subscribe WebSocket server
    3. Build a simple WebSocket server
    4. Enable compression for WebSocket messages
    5. Set per-socket contextual data on a WebSocket
    1. Write file

    2. Append content to a file
    3. Copy a file to another location
    4. Delete a file
    5. Write a Blob to a file
    6. Write a file incrementally
    7. Write a file to stdout
    8. Write a ReadableStream to a file
    9. Write a Response to a file
    10. Write a string to a file
    11. Write to stdout

Contributing

Refer to the Project > Contributing guide to start contributing to Bun.

License

Refer to the Project > License page for information about Bun's licensing.

stephane.bio

Made with Notion, Published on Super - 2026 © Stephane Boghossian

LinkedInInstagramMediumGitHubXBehanceDiscordPinterest