# Bun Documentation > Bun is a fast all-in-one JavaScript runtime & toolkit designed for speed, complete with a bundler, test runner, and Node.js-compatible package manager. This documentation covers all aspects of using Bun, from installation to advanced usage. ## Recent Bun Versions - [Bun v1.2.22](https://bun.com/blog/bun-v1.2.22.md): Async stack traces for better debugging, RFC 6455 compliant WebSocket client subprotocol negotiation, MySQL adapter improvements including affectedRows and lastInsertRowid support, JSX side effects preservation during bundling, event loop delay monitoring with perf_hooks, HTTP server idle connection management, --workspaces in bun run, function name removal during minification, and numerous Node.js compatibility fixes including child_process.spawnSync, socket.write with Uint8Array, crypto.verify RSA defaults, N-API improvements, HTMLRewriter error handling, fetch decompression fixes, Bun.SQL, and Bun.$ improvements. - [Bun v1.2.21](https://bun.com/blog/bun-v1.2.21.md): Bun.SQL now supports MySQL and SQLite, alongside PostgreSQL. Native YAML support. 500x faster postMessage(string). Bun.build() compile API, with cross-platform targets. Reduced idle CPU usage. Bun.stripANSI for SIMD-accelerated ANSI escape removal. bunx --package flag support. customizable User-Agent headers. Windows executable metadata embedding. and extensive Node.js compatibility improvements - [Bun v1.2.20](https://bun.com/blog/bun-v1.2.20.md): Reduced idle CPU usage. Improved `bun:test` diffing. Automatic `ETag` and `If-None-Match` in static routes for `Bun.serve`. 40x faster `AbortSignal.timeout`. Windows long path support. `WebAssembly.compileStreaming` and `WebAssembly.instantiateStreaming`. Many, many reliability improvements. - [Bun v1.2.19](https://bun.com/blog/bun-v1.2.19.md): 043 👍). Introduces `bun install --linker=isolated` for pnpm-style isolated node_modules, `bun why` for dependency tree understanding, `bun pm pkg` commands for package.json management, enhanced `node:fs.glob()` with array patterns and exclude options, `node:module.SourceMap` class and `findSourceMap()`, smarter `@types/bun` with automatic Node.js compatibility detection, plus numerous Node.js compatibility improvements, runtime bugfixes, bundler enhancements, and bun install optimizations. - [Bun v1.2.18](https://bun.com/blog/bun-v1.2.18.md): ReadableStream text(), json(), bytes(), blob(), WebSocket client compression with `permessage-deflate`, `bun pm version`, reduced memory usage for large `fetch()` and `S3` uploads, faster `napi_create_buffer`, faster sliced string handling in native addons, `fs.glob` now matches directories by default, `net.createConnection()` now validates `options.host`, `http.ClientRequest#flushHeaders` now correctly sends the request body, `net.connect` `keepAlive` and `keepAliveInitialDelay` options are now correctly handled, `fs.watchFile` emits `stop` on next tick, `net.Server` handles promise rejections in connection listeners, `net.connect` throws `ERR_INVALID_IP_ADDRESS` for non-string lookup results, `fs.watchFile` now ignores access time, `bun:sqlite` updated to SQLite 3.50.2, Bun now reports as Node.js v24.3.0, `bun test` now fails when no tests match a filter, `bun install` is faster for packages using `node-gyp`, `Math.sumPrecise` is now available, Node.js compatibility improvements. ## Documentation Sections ### Intro - [What is Bun?](https://bun.com/docs/index.md): Bun is an all-in-one runtime for JavaScript and TypeScript apps. Build, run, and test apps with one fast tool. - [Installation](https://bun.com/docs/installation.md): Install Bun with npm, Homebrew, Docker, or the official install script. - [Quickstart](https://bun.com/docs/quickstart.md): Get started with Bun by building and running a simple HTTP server in 6 lines of TypeScript. - [TypeScript](https://bun.com/docs/typescript.md): Install and configure type declarations for Bun's APIs ### Templating - [`bun init`](https://bun.com/docs/cli/init.md): Scaffold an empty Bun project. - [`bun create`](https://bun.com/docs/cli/bun-create.md): Scaffold a new Bun project from an official template or GitHub repo. ### Runtime - [`bun run`](https://bun.com/docs/cli/run.md): Use `bun run` to execute JavaScript/TypeScript files and package.json scripts. - [File types](https://bun.com/docs/runtime/loaders.md): Bun's runtime supports JavaScript/TypeScript files, JSX syntax, Wasm, JSON/TOML imports, and more. - [TypeScript](https://bun.com/docs/runtime/typescript.md): Bun can directly execute TypeScript files without additional configuration. - [JSX](https://bun.com/docs/runtime/jsx.md): Bun can directly execute TypeScript files without additional configuration. - [Environment variables](https://bun.com/docs/runtime/env.md): How to read and set environment variables, plus how to use them to configure Bun - [Bun APIs](https://bun.com/docs/runtime/bun-apis.md): Bun provides a set of highly optimized native APIs for performing common tasks. - [Web APIs](https://bun.com/docs/runtime/web-apis.md): Bun implements an array of Web-standard APIs like fetch, URL, and WebSocket. - [Node.js compatibility](https://bun.com/docs/runtime/nodejs-apis.md): Bun aims for full Node.js compatibility. This page tracks the current compatibility status. - [Single-file executable](https://bun.com/docs/bundler/executables.md): Compile a TypeScript or JavaScript file to a standalone executable - [Plugins](https://bun.com/docs/runtime/plugins.md): Implement custom loaders and module resolution logic with Bun's plugin system. - [Watch mode](https://bun.com/docs/runtime/hot.md): Reload your application & tests automatically. - [Module resolution](https://bun.com/docs/runtime/modules.md): Bun uses ESM and implements an extended version of the Node.js module resolution algorithm. - [Auto-install](https://bun.com/docs/runtime/autoimport.md): Never use node_modules again. Bun can optionally auto-install your dependencies on the fly. - [bunfig.toml](https://bun.com/docs/runtime/bunfig.md): Bun's runtime is configurable with environment variables and the bunfig.toml config file. - [Debugger](https://bun.com/docs/runtime/debugger.md): Debug your code with Bun's web-based debugger or VS Code extension ### Package manager - [`bun install`](https://bun.com/docs/cli/install.md): Install all dependencies with `bun install`, or manage dependencies with `bun add` and `bun remove`. - [`bun add`](https://bun.com/docs/cli/add.md): Add dependencies to your project. - [`bun remove`](https://bun.com/docs/cli/remove.md): Remove dependencies from your project. - [`bun update`](https://bun.com/docs/cli/update.md): Update your project's dependencies. - [`bun publish`](https://bun.com/docs/cli/publish.md): Publish your package to an npm registry. - [`bun outdated`](https://bun.com/docs/cli/outdated.md): Check for outdated dependencies. - [`bun link`](https://bun.com/docs/cli/link.md): Install local packages as dependencies in your project. - [`bun pm`](https://bun.com/docs/cli/pm.md): Utilities relating to package management with Bun. - [`bun why`](https://bun.com/docs/cli/why.md): Explains why a package is installed in your project. - [Global cache](https://bun.com/docs/install/cache.md): Bun's package manager installs all packages into a shared global cache to avoid redundant re-downloads. - [Isolated installs](https://bun.com/docs/install/isolated.md): Create strict dependency isolation, preventing phantom dependencies. - [Workspaces](https://bun.com/docs/install/workspaces.md): Bun's package manager supports workspaces and monorepo development workflows. - [Catalogs](https://bun.com/docs/install/catalogs.md): Use catalogs to share dependency versions between packages in a monorepo. - [Lifecycle scripts](https://bun.com/docs/install/lifecycle.md): How Bun handles package lifecycle scripts with trustedDependencies - [Filter](https://bun.com/docs/cli/filter.md): Run scripts in multiple packages in parallel - [Lockfile](https://bun.com/docs/install/lockfile.md): Bun's lockfile `bun.lock` tracks your resolved dependency tree, making future installs fast and repeatable. - [Scopes and registries](https://bun.com/docs/install/registries.md): How to configure private scopes, custom package registries, authenticating with npm token, and more. - [Overrides and resolutions](https://bun.com/docs/install/overrides.md): Specify version ranges for nested dependencies - [Patch dependencies](https://bun.com/docs/install/patch.md): Patch dependencies in your project to fix bugs or add features without vendoring the entire package. - [Audit dependencies](https://bun.com/docs/install/audit.md): Check installed packages for vulnerabilities. - [.npmrc support](https://bun.com/docs/install/npmrc.md): Bun supports loading some configuration options from .npmrc - [Security Scanner API](https://bun.com/docs/install/security-scanner-api.md): Scan your project for vulnerabilities with Bun's security scanner API. ### Bundler - [`Bun.build`](https://bun.com/docs/bundler): Bundle code for consumption in the browser with Bun's native bundler. - [HTML & static sites](https://bun.com/docs/bundler/html.md): Zero-config HTML bundler for single-page apps and multi-page apps. Automatic bundling, TailwindCSS plugins, TypeScript, JSX, React support, and incredibly fast builds - [CSS](https://bun.com/docs/bundler/css.md): Production ready CSS bundler with support for modern CSS features, CSS modules, and more. - [Fullstack Dev Server](https://bun.com/docs/bundler/fullstack.md): Serve your frontend and backend from the same app with Bun's dev server. - [Hot reloading](https://bun.com/docs/bundler/hmr.md): Update modules in a running application without reloading the page using import.meta.hot - [Loaders](https://bun.com/docs/bundler/loaders.md): Bun's built-in loaders for the bundler and runtime - [Plugins](https://bun.com/docs/bundler/plugins.md): Implement custom loaders and module resolution logic with Bun's plugin system. - [Macros](https://bun.com/docs/bundler/macros.md): Run JavaScript functions at bundle-time and inline the results into your bundle - [vs esbuild](https://bun.com/docs/bundler/vs-esbuild.md): Guides for migrating from other bundlers to Bun. ### Test runner - [`bun test`](https://bun.com/docs/cli/test.md): Bun's test runner uses Jest-compatible syntax but runs 100x faster. - [Writing tests](https://bun.com/docs/test/writing.md): Write your tests using Jest-like expect matchers, plus setup/teardown hooks, snapshot testing, and more - [Watch mode](https://bun.com/docs/test/hot.md): Reload your tests automatically on change. - [Lifecycle hooks](https://bun.com/docs/test/lifecycle.md): Add lifecycle hooks to your tests that run before/after each test or test run - [Mocks](https://bun.com/docs/test/mocks.md): Mocks functions and track method calls - [Snapshots](https://bun.com/docs/test/snapshots.md): Add lifecycle hooks to your tests that run before/after each test or test run - [Dates and times](https://bun.com/docs/test/time.md): Control the date & time in your tests for more reliable and deterministic tests - [Code coverage](https://bun.com/docs/test/coverage.md): Generate code coverage reports with `bun test --coverage` - [Test reporters](https://bun.com/docs/test/reporters.md): Add a junit reporter to your test runs - [Test configuration](https://bun.com/docs/test/configuration.md): Configure the test runner with bunfig.toml - [Runtime behavior](https://bun.com/docs/test/runtime-behavior.md): Learn how the test runner affects Bun's runtime behavior - [Finding tests](https://bun.com/docs/test/discovery.md): Learn how the test runner discovers tests - [DOM testing](https://bun.com/docs/test/dom.md): Write headless tests for UI and React/Vue/Svelte/Lit components with happy-dom ### Package runner - [`bunx`](https://bun.com/docs/cli/bunx.md): Use `bunx` to auto-install and run executable packages from npm. ### API - [HTTP server](https://bun.com/docs/api/http.md): Bun implements a fast HTTP server built on Request/Response objects, along with supporting node:http APIs. - [HTTP client](https://bun.com/docs/api/fetch.md): Bun implements Web-standard fetch with some Bun-native extensions. - [WebSockets](https://bun.com/docs/api/websockets.md): Bun supports server-side WebSockets with on-the-fly compression, TLS support, and a Bun-native pubsub API. - [Workers](https://bun.com/docs/api/workers.md): Run code in a separate thread with Bun's native Worker API. - [Binary data](https://bun.com/docs/api/binary-data.md): How to represent and manipulate binary data in Bun. - [Streams](https://bun.com/docs/api/streams.md): Reading, writing, and manipulating streams of data in Bun. - [SQL](https://bun.com/docs/api/sql.md): Bun provides fast, native bindings for interacting with PostgreSQL databases. - [S3 Object Storage](https://bun.com/docs/api/s3.md): Bun provides fast, native bindings for interacting with S3-compatible object storage services. - [File I/O](https://bun.com/docs/api/file-io.md): Read and write files fast with Bun's heavily optimized file system API. - [Redis client](https://bun.com/docs/api/redis.md): Bun provides a fast, native Redis client with automatic command pipelining for better performance. - [import.meta](https://bun.com/docs/api/import-meta.md): Module-scoped metadata and utilities - [SQLite](https://bun.com/docs/api/sqlite.md): The fastest SQLite driver for JavaScript is baked directly into Bun. - [FileSystemRouter](https://bun.com/docs/api/file-system-router.md): Resolve incoming HTTP requests against a local file system directory with Bun's fast, Next.js-compatible router. - [TCP sockets](https://bun.com/docs/api/tcp.md): Bun's native API implements Web-standard TCP Sockets, plus a Bun-native API for building fast TCP servers. - [UDP sockets](https://bun.com/docs/api/udp.md): Bun's native API implements fast and flexible UDP sockets. - [Globals](https://bun.com/docs/api/globals.md): Bun implements a range of Web APIs, Node.js APIs, and Bun-native APIs that are available in the global scope. - [$ Shell](https://bun.com/docs/runtime/shell.md): Bun's cross-platform shell-scripting API makes shell scripting with JavaScript fun - [Child processes](https://bun.com/docs/api/spawn.md): Spawn sync and async child processes with easily configurable input and output streams. - [YAML](https://bun.com/docs/api/yaml.md): Bun.YAML.parse(string) lets you parse YAML files in JavaScript - [HTMLRewriter](https://bun.com/docs/api/html-rewriter.md): Parse and transform HTML with Bun's native HTMLRewriter API, inspired by Cloudflare Workers. - [Hashing](https://bun.com/docs/api/hashing.md): Native support for a range of fast hashing algorithms. - [Console](https://bun.com/docs/api/console.md): Bun implements a Node.js-compatible `console` object with colorized output and deep pretty-printing. - [Cookie](https://bun.com/docs/api/cookie.md): Bun's native Cookie API simplifies working with HTTP cookies. - [FFI](https://bun.com/docs/api/ffi.md): Call native code from JavaScript with Bun's foreign function interface (FFI) API. - [C Compiler](https://bun.com/docs/api/cc.md): Build & run native C from JavaScript with Bun's native C compiler API - [Secrets](https://bun.com/docs/api/secrets.md): Store and retrieve sensitive credentials securely using the operating system's native credential storage APIs. - [Testing](https://bun.com/docs/cli/test.md): Bun's built-in test runner is fast and uses Jest-compatible syntax. - [Utils](https://bun.com/docs/api/utils.md): Bun implements a set of utilities that are commonly required by developers. - [Node-API](https://bun.com/docs/api/node-api.md): Bun implements the Node-API spec for building native addons. - [Glob](https://bun.com/docs/api/glob.md): Bun includes a fast native Glob implementation for matching file paths. - [DNS](https://bun.com/docs/api/dns.md): Resolve domain names to IP addresses. - [Semver](https://bun.com/docs/api/semver.md): Bun's native Semver implementation is 20x faster than the popular `node-semver` package. - [Color](https://bun.com/docs/api/color.md): Bun's color function leverages Bun's CSS parser for parsing, normalizing, and converting colors from user input to a variety of output formats. - [Transpiler](https://bun.com/docs/api/transpiler.md): Bun exposes its internal transpiler as a pluggable API. ### Project - [Roadmap](https://bun.com/docs/project/roadmap.md): Track Bun's near-term and long-term goals. - [Benchmarking](https://bun.com/docs/project/benchmarking.md): Bun is designed for performance. Learn how to benchmark Bun yourself. - [Contributing](https://bun.com/docs/project/contributing.md): Learn how to contribute to Bun and get your local development environment up and running. - [Building Windows](https://bun.com/docs/project/building-windows.md): Learn how to setup a development environment for contributing to the Windows build of Bun. - [Bindgen](https://bun.com/docs/project/bindgen.md): About the bindgen code generator - [License](https://bun.com/docs/project/licensing.md): Bun is a MIT-licensed project with a large number of statically-linked dependencies with various licenses. ## Guides ### Guides: Binary data - [Convert a Blob to a DataView](https://bun.com/guides/binary/blob-to-dataview.md) - [Convert a Blob to a ReadableStream](https://bun.com/guides/binary/blob-to-stream.md) - [Convert a Blob to a string](https://bun.com/guides/binary/blob-to-string.md) - [Convert a Blob to a Uint8Array](https://bun.com/guides/binary/blob-to-typedarray.md) - [Convert a Blob to an ArrayBuffer](https://bun.com/guides/binary/blob-to-arraybuffer.md) - [Convert a Buffer to a blob](https://bun.com/guides/binary/buffer-to-blob.md) - [Convert a Buffer to a ReadableStream](https://bun.com/guides/binary/buffer-to-readablestream.md) - [Convert a Buffer to a string](https://bun.com/guides/binary/buffer-to-string.md) - [Convert a Buffer to a Uint8Array](https://bun.com/guides/binary/buffer-to-typedarray.md) - [Convert a Buffer to an ArrayBuffer](https://bun.com/guides/binary/buffer-to-arraybuffer.md) - [Convert a DataView to a string](https://bun.com/guides/binary/dataview-to-string.md) - [Convert a Uint8Array to a Blob](https://bun.com/guides/binary/typedarray-to-blob.md) - [Convert a Uint8Array to a Buffer](https://bun.com/guides/binary/typedarray-to-buffer.md) - [Convert a Uint8Array to a DataView](https://bun.com/guides/binary/typedarray-to-dataview.md) - [Convert a Uint8Array to a ReadableStream](https://bun.com/guides/binary/typedarray-to-readablestream.md) - [Convert a Uint8Array to a string](https://bun.com/guides/binary/typedarray-to-string.md) - [Convert a Uint8Array to an ArrayBuffer](https://bun.com/guides/binary/typedarray-to-arraybuffer.md) - [Convert an ArrayBuffer to a Blob](https://bun.com/guides/binary/arraybuffer-to-blob.md) - [Convert an ArrayBuffer to a Buffer](https://bun.com/guides/binary/arraybuffer-to-buffer.md) - [Convert an ArrayBuffer to a string](https://bun.com/guides/binary/arraybuffer-to-string.md) - [Convert an ArrayBuffer to a Uint8Array](https://bun.com/guides/binary/arraybuffer-to-typedarray.md) - [Convert an ArrayBuffer to an array of numbers](https://bun.com/guides/binary/arraybuffer-to-array.md) ### Guides: Deployment - [Deploy a Bun application on Railway](https://bun.com/guides/deployment/railway.md): Deploy Bun applications to Railway with this step-by-step guide covering CLI and dashboard methods, optional PostgreSQL setup, and automatic SSL configuration. ### Guides: Ecosystem - [Add Sentry to a Bun app](https://bun.com/guides/ecosystem/sentry.md) - [Build a frontend using Vite and Bun](https://bun.com/guides/ecosystem/vite.md) - [Build a React app with Bun](https://bun.com/guides/ecosystem/react.md) - [Build an app with Astro and Bun](https://bun.com/guides/ecosystem/astro.md) - [Build an app with Next.js and Bun](https://bun.com/guides/ecosystem/nextjs.md) - [Build an app with Nuxt and Bun](https://bun.com/guides/ecosystem/nuxt.md) - [Build an app with Qwik and Bun](https://bun.com/guides/ecosystem/qwik.md) - [Build an app with Remix and Bun](https://bun.com/guides/ecosystem/remix.md) - [Build an app with SolidStart and Bun](https://bun.com/guides/ecosystem/solidstart.md) - [Build an app with SvelteKit and Bun](https://bun.com/guides/ecosystem/sveltekit.md) - [Build an HTTP server using Elysia and Bun](https://bun.com/guides/ecosystem/elysia.md) - [Build an HTTP server using Express and Bun](https://bun.com/guides/ecosystem/express.md) - [Build an HTTP server using Hono and Bun](https://bun.com/guides/ecosystem/hono.md) - [Build an HTTP server using StricJS and Bun](https://bun.com/guides/ecosystem/stric.md) - [Containerize a Bun application with Docker](https://bun.com/guides/ecosystem/docker.md) - [Create a Discord bot](https://bun.com/guides/ecosystem/discordjs.md) - [Deploy a Bun application on Render](https://bun.com/guides/ecosystem/render.md) - [Read and write data to MongoDB using Mongoose and Bun](https://bun.com/guides/ecosystem/mongoose.md) - [Run Bun as a daemon with PM2](https://bun.com/guides/ecosystem/pm2.md) - [Run Bun as a daemon with systemd](https://bun.com/guides/ecosystem/systemd.md) - [Server-side render (SSR) a React component](https://bun.com/guides/ecosystem/ssr-react.md) - [Use Drizzle ORM with Bun](https://bun.com/guides/ecosystem/drizzle.md) - [Use EdgeDB with Bun](https://bun.com/guides/ecosystem/edgedb.md) - [Use Neon Postgres through Drizzle ORM](https://bun.com/guides/ecosystem/neon-drizzle.md) - [Use Neon's Serverless Postgres with Bun](https://bun.com/guides/ecosystem/neon-serverless-postgres.md) - [Use Prisma with Bun](https://bun.com/guides/ecosystem/prisma.md) ### Guides: HTMLRewriter - [Extract links from a webpage using HTMLRewriter](https://bun.com/guides/html-rewriter/extract-links.md) - [Extract social share images and Open Graph tags](https://bun.com/guides/html-rewriter/extract-social-meta.md) ### Guides: HTTP - [Common HTTP server usage](https://bun.com/guides/http/server.md) - [Configure TLS on an HTTP server](https://bun.com/guides/http/tls.md) - [fetch with unix domain sockets in Bun](https://bun.com/guides/http/fetch-unix.md) - [Hot reload an HTTP server](https://bun.com/guides/http/hot.md) - [Proxy HTTP requests using fetch()](https://bun.com/guides/http/proxy.md) - [Send an HTTP request using fetch](https://bun.com/guides/http/fetch.md) - [Start a cluster of HTTP servers](https://bun.com/guides/http/cluster.md): Run multiple HTTP servers concurrently via the "reusePort" option to share the same port across multiple processes - [Stream a file as an HTTP Response](https://bun.com/guides/http/stream-file.md) - [Streaming HTTP Server with Async Iterators](https://bun.com/guides/http/stream-iterator.md) - [Streaming HTTP Server with Node.js Streams](https://bun.com/guides/http/stream-node-streams-in-bun.md) - [Upload files via HTTP using FormData](https://bun.com/guides/http/file-uploads.md) - [Write a simple HTTP server](https://bun.com/guides/http/simple.md) ### Guides: Package manager - [Add a dependency](https://bun.com/guides/install/add.md) - [Add a development dependency](https://bun.com/guides/install/add-dev.md) - [Add a Git dependency](https://bun.com/guides/install/add-git.md) - [Add a peer dependency](https://bun.com/guides/install/add-peer.md) - [Add a tarball dependency](https://bun.com/guides/install/add-tarball.md) - [Add a trusted dependency](https://bun.com/guides/install/trusted.md) - [Add an optional dependency](https://bun.com/guides/install/add-optional.md) - [Configure a private registry for an organization scope with bun install](https://bun.com/guides/install/registry-scope.md) - [Configure git to diff Bun's lockb lockfile](https://bun.com/guides/install/git-diff-bun-lockfile.md) - [Configuring a monorepo using workspaces](https://bun.com/guides/install/workspaces.md) - [Generate a yarn-compatible lockfile](https://bun.com/guides/install/yarnlock.md) - [Install a package under a different name](https://bun.com/guides/install/npm-alias.md) - [Install dependencies with Bun in GitHub Actions](https://bun.com/guides/install/cicd.md) - [Migrate from npm install to bun install](https://bun.com/guides/install/from-npm-install-to-bun-install.md) - [Override the default npm registry for bun install](https://bun.com/guides/install/custom-registry.md) - [Using bun install with an Azure Artifacts npm registry](https://bun.com/guides/install/azure-artifacts.md) - [Using bun install with Artifactory](https://bun.com/guides/install/jfrog-artifactory.md) ### Guides: Processes - [Get the process uptime in nanoseconds](https://bun.com/guides/process/nanoseconds.md) - [Listen for CTRL+C](https://bun.com/guides/process/ctrl-c.md) - [Listen to OS signals](https://bun.com/guides/process/os-signals.md) - [Parse command-line arguments](https://bun.com/guides/process/argv.md) - [Read from stdin](https://bun.com/guides/process/stdin.md) - [Read stderr from a child process](https://bun.com/guides/process/spawn-stderr.md) - [Read stdout from a child process](https://bun.com/guides/process/spawn-stdout.md) - [Spawn a child process](https://bun.com/guides/process/spawn.md) - [Spawn a child process and communicate using IPC](https://bun.com/guides/process/ipc.md) ### Guides: Reading files - [Check if a file exists](https://bun.com/guides/read-file/exists.md) - [Get the MIME type of a file](https://bun.com/guides/read-file/mime.md) - [Read a file as a ReadableStream](https://bun.com/guides/read-file/stream.md) - [Read a file as a string](https://bun.com/guides/read-file/string.md) - [Read a file to a Buffer](https://bun.com/guides/read-file/buffer.md) - [Read a file to a Uint8Array](https://bun.com/guides/read-file/uint8array.md) - [Read a file to an ArrayBuffer](https://bun.com/guides/read-file/arraybuffer.md) - [Read a JSON file](https://bun.com/guides/read-file/json.md) - [Watch a directory for changes](https://bun.com/guides/read-file/watch.md) ### Guides: Runtime - [Build-time constants with --define](https://bun.com/guides/runtime/build-time-constants.md) - [Codesign a single-file JavaScript executable on macOS](https://bun.com/guides/runtime/codesign-macos-executable.md): Fix the "can't be opened because it is from an unidentified developer" Gatekeeper warning when running your JavaScript executable. - [Debugging Bun with the VS Code extension](https://bun.com/guides/runtime/vscode-debugger.md) - [Debugging Bun with the web debugger](https://bun.com/guides/runtime/web-debugger.md) - [Define and replace static globals & constants](https://bun.com/guides/runtime/define-constant.md) - [Delete directories](https://bun.com/guides/runtime/delete-directory.md) - [Delete files](https://bun.com/guides/runtime/delete-file.md) - [Import a HTML file as text](https://bun.com/guides/runtime/import-html.md) - [Import a JSON file](https://bun.com/guides/runtime/import-json.md) - [Import a TOML file](https://bun.com/guides/runtime/import-toml.md) - [Import a YAML file](https://bun.com/guides/runtime/import-yaml.md) - [Inspect memory usage using V8 heap snapshots](https://bun.com/guides/runtime/heap-snapshot.md) - [Install and run Bun in GitHub Actions](https://bun.com/guides/runtime/cicd.md) - [Install TypeScript declarations for Bun](https://bun.com/guides/runtime/typescript.md) - [Re-map import paths](https://bun.com/guides/runtime/tsconfig-paths.md) - [Read environment variables](https://bun.com/guides/runtime/read-env.md) - [Run a Shell Command](https://bun.com/guides/runtime/shell.md) - [Set a time zone in Bun](https://bun.com/guides/runtime/timezone.md) - [Set environment variables](https://bun.com/guides/runtime/set-env.md) ### Guides: Streams - [Convert a Node.js Readable to a Blob](https://bun.com/guides/streams/node-readable-to-blob.md) - [Convert a Node.js Readable to a string](https://bun.com/guides/streams/node-readable-to-string.md) - [Convert a Node.js Readable to an ArrayBuffer](https://bun.com/guides/streams/node-readable-to-arraybuffer.md) - [Convert a Node.js Readable to an Uint8Array](https://bun.com/guides/streams/node-readable-to-uint8array.md) - [Convert a Node.js Readable to JSON](https://bun.com/guides/streams/node-readable-to-json.md) - [Convert a ReadableStream to a Blob](https://bun.com/guides/streams/to-blob.md) - [Convert a ReadableStream to a Buffer](https://bun.com/guides/streams/to-buffer.md) - [Convert a ReadableStream to a string](https://bun.com/guides/streams/to-string.md) - [Convert a ReadableStream to a Uint8Array](https://bun.com/guides/streams/to-typedarray.md) - [Convert a ReadableStream to an array of chunks](https://bun.com/guides/streams/to-array.md) - [Convert a ReadableStream to an ArrayBuffer](https://bun.com/guides/streams/to-arraybuffer.md) - [Convert a ReadableStream to JSON](https://bun.com/guides/streams/to-json.md) ### Guides: Test runner - [Bail early with the Bun test runner](https://bun.com/guides/test/bail.md) - [Generate code coverage reports with the Bun test runner](https://bun.com/guides/test/coverage.md) - [import, require, and test Svelte components with bun test](https://bun.com/guides/test/svelte-test.md) - [Mark a test as a "todo" with the Bun test runner](https://bun.com/guides/test/todo-tests.md) - [Migrate from Jest to Bun's test runner](https://bun.com/guides/test/migrate-from-jest.md) - [Mock functions in `bun test`](https://bun.com/guides/test/mock-functions.md) - [Re-run tests multiple times with the Bun test runner](https://bun.com/guides/test/rerun-each.md) - [Run tests in watch mode with Bun](https://bun.com/guides/test/watch-mode.md) - [Run your tests with the Bun test runner](https://bun.com/guides/test/run-tests.md) - [Set a code coverage threshold with the Bun test runner](https://bun.com/guides/test/coverage-threshold.md) - [Set a per-test timeout with the Bun test runner](https://bun.com/guides/test/timeout.md) - [Set the system time in Bun's test runner](https://bun.com/guides/test/mock-clock.md) - [Skip tests with the Bun test runner](https://bun.com/guides/test/skip-tests.md) - [Spy on methods in `bun test`](https://bun.com/guides/test/spy-on.md) - [Update snapshots in `bun test`](https://bun.com/guides/test/update-snapshots.md) - [Use snapshot testing in `bun test`](https://bun.com/guides/test/snapshot.md) - [Using Testing Library with Bun](https://bun.com/guides/test/testing-library.md) - [Write browser DOM tests with Bun and happy-dom](https://bun.com/guides/test/happy-dom.md) ### Guides: Utilities - [Check if the current file is the entrypoint](https://bun.com/guides/util/entrypoint.md) - [Check if two objects are deeply equal](https://bun.com/guides/util/deep-equals.md) - [Compress and decompress data with DEFLATE](https://bun.com/guides/util/deflate.md) - [Compress and decompress data with gzip](https://bun.com/guides/util/gzip.md) - [Convert a file URL to an absolute path](https://bun.com/guides/util/file-url-to-path.md) - [Convert an absolute path to a file URL](https://bun.com/guides/util/path-to-file-url.md) - [Detect when code is executed with Bun](https://bun.com/guides/util/detect-bun.md) - [Encode and decode base64 strings](https://bun.com/guides/util/base64.md) - [Escape an HTML string](https://bun.com/guides/util/escape-html.md) - [Generate a UUID](https://bun.com/guides/util/javascript-uuid.md) - [Get the absolute path of the current file](https://bun.com/guides/util/import-meta-path.md) - [Get the absolute path to the current entrypoint](https://bun.com/guides/util/main.md) - [Get the current Bun version](https://bun.com/guides/util/version.md) - [Get the directory of the current file](https://bun.com/guides/util/import-meta-dir.md) - [Get the file name of the current file](https://bun.com/guides/util/import-meta-file.md) - [Get the path to an executable bin file](https://bun.com/guides/util/which-path-to-executable-bin.md) - [Hash a password](https://bun.com/guides/util/hash-a-password.md) - [Sleep for a fixed number of milliseconds](https://bun.com/guides/util/sleep.md) ### Guides: WebSocket - [Build a publish-subscribe WebSocket server](https://bun.com/guides/websocket/pubsub.md) - [Build a simple WebSocket server](https://bun.com/guides/websocket/simple.md) - [Enable compression for WebSocket messages](https://bun.com/guides/websocket/compression.md) - [Set per-socket contextual data on a WebSocket](https://bun.com/guides/websocket/context.md) ### Guides: Writing files - [Append content to a file](https://bun.com/guides/write-file/append.md) - [Copy a file to another location](https://bun.com/guides/write-file/file-cp.md) - [Delete a file](https://bun.com/guides/write-file/unlink.md) - [Write a Blob to a file](https://bun.com/guides/write-file/blob.md) - [Write a file incrementally](https://bun.com/guides/write-file/filesink.md) - [Write a file to stdout](https://bun.com/guides/write-file/cat.md) - [Write a ReadableStream to a file](https://bun.com/guides/write-file/stream.md) - [Write a Response to a file](https://bun.com/guides/write-file/response.md) - [Write a string to a file](https://bun.com/guides/write-file/basic.md) - [Write to stdout](https://bun.com/guides/write-file/stdout.md)