mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
bun.sh -> bun.com (#20909)
This commit is contained in:
2
.github/ISSUE_TEMPLATE/2-bug-report.yml
vendored
2
.github/ISSUE_TEMPLATE/2-bug-report.yml
vendored
@@ -12,7 +12,7 @@ body:
|
||||
If you need help or support using Bun, and are not reporting a bug, please
|
||||
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can ask questions in the [`#help`](https://discord.gg/32EtH6p7HN) forum.
|
||||
|
||||
Make sure you are running the [latest](https://bun.sh/docs/installation#upgrading) version of Bun.
|
||||
Make sure you are running the [latest](https://bun.com/docs/installation#upgrading) version of Bun.
|
||||
The bug you are experiencing may already have been fixed.
|
||||
|
||||
Please try to include as much information as possible.
|
||||
|
||||
@@ -10,7 +10,7 @@ body:
|
||||
If you need help or support using Bun, and are not reporting a bug, please
|
||||
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can ask questions in the [`#help`](https://discord.gg/32EtH6p7HN) forum.
|
||||
|
||||
Make sure you are running the [latest](https://bun.sh/docs/installation#upgrading) version of Bun.
|
||||
Make sure you are running the [latest](https://bun.com/docs/installation#upgrading) version of Bun.
|
||||
The bug you are experiencing may already have been fixed.
|
||||
|
||||
Please try to include as much information as possible.
|
||||
|
||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -202,7 +202,7 @@ jobs:
|
||||
body: |
|
||||
Update `bun-types` version to ${{ steps.bun-version.outputs.BUN_VERSION }}
|
||||
|
||||
https://bun.sh/blog/${{ env.BUN_VERSION }}
|
||||
https://bun.com/blog/${{ env.BUN_VERSION }}
|
||||
push-to-fork: oven-sh/DefinitelyTyped
|
||||
branch: ${{env.BUN_VERSION}}
|
||||
docker:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Configuring a development environment for Bun can take 10-30 minutes depending on your internet connection and computer speed. You will need ~10GB of free disk space for the repository and build artifacts.
|
||||
|
||||
If you are using Windows, please refer to [this guide](https://bun.sh/docs/project/building-windows)
|
||||
If you are using Windows, please refer to [this guide](https://bun.com/docs/project/building-windows)
|
||||
|
||||
## Install Dependencies
|
||||
|
||||
@@ -37,7 +37,7 @@ Before starting, you will need to already have a release build of Bun installed,
|
||||
{% codetabs %}
|
||||
|
||||
```bash#Native
|
||||
$ curl -fsSL https://bun.sh/install | bash
|
||||
$ curl -fsSL https://bun.com/install | bash
|
||||
```
|
||||
|
||||
```bash#npm
|
||||
|
||||
18
Makefile
18
Makefile
@@ -980,7 +980,7 @@ release-create-auto-updater:
|
||||
.PHONY: release-create
|
||||
release-create:
|
||||
gh release create --title "bun v$(PACKAGE_JSON_VERSION)" "$(BUN_BUILD_TAG)"
|
||||
gh release create --repo=$(BUN_AUTO_UPDATER_REPO) --title "bun v$(PACKAGE_JSON_VERSION)" "$(BUN_BUILD_TAG)" -n "See https://github.com/oven-sh/bun/releases/tag/$(BUN_BUILD_TAG) for release notes. Using the install script or bun upgrade is the recommended way to install bun. Join bun's Discord to get access https://bun.sh/discord"
|
||||
gh release create --repo=$(BUN_AUTO_UPDATER_REPO) --title "bun v$(PACKAGE_JSON_VERSION)" "$(BUN_BUILD_TAG)" -n "See https://github.com/oven-sh/bun/releases/tag/$(BUN_BUILD_TAG) for release notes. Using the install script or bun upgrade is the recommended way to install bun. Join bun's Discord to get access https://bun.com/discord"
|
||||
|
||||
release-bin-entitlements:
|
||||
|
||||
@@ -1977,7 +1977,7 @@ integration-test-dev: # to run integration tests
|
||||
USE_EXISTING_PROCESS=true TEST_SERVER_URL=http://localhost:3000 node test/scripts/browser.js
|
||||
|
||||
copy-install:
|
||||
cp src/cli/install.sh ../bun.sh/docs/install.html
|
||||
cp src/cli/install.sh ../bun.com/docs/install.html
|
||||
|
||||
copy-to-bun-release-dir: copy-to-bun-release-dir-bin copy-to-bun-release-dir-dsym
|
||||
|
||||
@@ -2019,28 +2019,28 @@ vendor-dev: assert-deps submodule npm-install-dev vendor-without-npm
|
||||
.PHONY: bun
|
||||
bun:
|
||||
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
|
||||
@echo 'See https://bun.sh/docs/project/contributing for more details'
|
||||
@echo 'See https://bun.com/docs/project/contributing for more details'
|
||||
|
||||
cpp:
|
||||
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
|
||||
@echo 'See https://bun.sh/docs/project/contributing for more details'
|
||||
@echo 'See https://bun.com/docs/project/contributing for more details'
|
||||
|
||||
zig:
|
||||
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
|
||||
@echo 'See https://bun.sh/docs/project/contributing for more details'
|
||||
@echo 'See https://bun.com/docs/project/contributing for more details'
|
||||
|
||||
dev:
|
||||
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
|
||||
@echo 'See https://bun.sh/docs/project/contributing for more details'
|
||||
@echo 'See https://bun.com/docs/project/contributing for more details'
|
||||
|
||||
setup:
|
||||
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
|
||||
@echo 'See https://bun.sh/docs/project/contributing for more details'
|
||||
@echo 'See https://bun.com/docs/project/contributing for more details'
|
||||
|
||||
bindings:
|
||||
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
|
||||
@echo 'See https://bun.sh/docs/project/contributing for more details'
|
||||
@echo 'See https://bun.com/docs/project/contributing for more details'
|
||||
|
||||
help:
|
||||
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
|
||||
@echo 'See https://bun.sh/docs/project/contributing for more details'
|
||||
@echo 'See https://bun.com/docs/project/contributing for more details'
|
||||
|
||||
588
README.md
588
README.md
@@ -1,16 +1,16 @@
|
||||
<p align="center">
|
||||
<a href="https://bun.sh"><img src="https://github.com/user-attachments/assets/50282090-adfd-4ddb-9e27-c30753c6b161" alt="Logo" height=170></a>
|
||||
<a href="https://bun.com"><img src="https://github.com/user-attachments/assets/50282090-adfd-4ddb-9e27-c30753c6b161" alt="Logo" height=170></a>
|
||||
</p>
|
||||
<h1 align="center">Bun</h1>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://bun.sh/discord" target="_blank"><img height=20 src="https://img.shields.io/discord/876711213126520882" /></a>
|
||||
<a href="https://bun.com/discord" target="_blank"><img height=20 src="https://img.shields.io/discord/876711213126520882" /></a>
|
||||
<img src="https://img.shields.io/github/stars/oven-sh/bun" alt="stars">
|
||||
<a href="https://twitter.com/jarredsumner/status/1542824445810642946"><img src="https://img.shields.io/static/v1?label=speed&message=fast&color=success" alt="Bun speed" /></a>
|
||||
</p>
|
||||
|
||||
<div align="center">
|
||||
<a href="https://bun.sh/docs">Documentation</a>
|
||||
<a href="https://bun.com/docs">Documentation</a>
|
||||
<span> • </span>
|
||||
<a href="https://discord.com/invite/CXdq2DP29u">Discord</a>
|
||||
<span> • </span>
|
||||
@@ -20,7 +20,7 @@
|
||||
<br />
|
||||
</div>
|
||||
|
||||
### [Read the docs →](https://bun.sh/docs)
|
||||
### [Read the docs →](https://bun.com/docs)
|
||||
|
||||
## What is Bun?
|
||||
|
||||
@@ -47,14 +47,14 @@ 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.
|
||||
|
||||
> **x64 users** — if you see "illegal instruction" or similar errors, check our [CPU requirements](https://bun.sh/docs/installation#cpu-requirements-and-baseline-builds)
|
||||
> **x64 users** — if you see "illegal instruction" or similar errors, check our [CPU requirements](https://bun.com/docs/installation#cpu-requirements-and-baseline-builds)
|
||||
|
||||
```sh
|
||||
# with install script (recommended)
|
||||
curl -fsSL https://bun.sh/install | bash
|
||||
curl -fsSL https://bun.com/install | bash
|
||||
|
||||
# on windows
|
||||
powershell -c "irm bun.sh/install.ps1 | iex"
|
||||
powershell -c "irm bun.com/install.ps1 | iex"
|
||||
|
||||
# with npm
|
||||
npm install -g bun
|
||||
@@ -87,351 +87,329 @@ bun upgrade --canary
|
||||
## Quick links
|
||||
|
||||
- Intro
|
||||
|
||||
- [What is Bun?](https://bun.sh/docs/index)
|
||||
- [Installation](https://bun.sh/docs/installation)
|
||||
- [Quickstart](https://bun.sh/docs/quickstart)
|
||||
- [TypeScript](https://bun.sh/docs/typescript)
|
||||
- [What is Bun?](https://bun.com/docs/index)
|
||||
- [Installation](https://bun.com/docs/installation)
|
||||
- [Quickstart](https://bun.com/docs/quickstart)
|
||||
- [TypeScript](https://bun.com/docs/typescript)
|
||||
|
||||
- Templating
|
||||
|
||||
- [`bun init`](https://bun.sh/docs/cli/init)
|
||||
- [`bun create`](https://bun.sh/docs/cli/bun-create)
|
||||
- [`bun init`](https://bun.com/docs/cli/init)
|
||||
- [`bun create`](https://bun.com/docs/cli/bun-create)
|
||||
|
||||
- CLI
|
||||
|
||||
- [`bun upgrade`](https://bun.sh/docs/cli/bun-upgrade)
|
||||
- [`bun upgrade`](https://bun.com/docs/cli/bun-upgrade)
|
||||
|
||||
- Runtime
|
||||
|
||||
- [`bun run`](https://bun.sh/docs/cli/run)
|
||||
- [File types (Loaders)](https://bun.sh/docs/runtime/loaders)
|
||||
- [TypeScript](https://bun.sh/docs/runtime/typescript)
|
||||
- [JSX](https://bun.sh/docs/runtime/jsx)
|
||||
- [Environment variables](https://bun.sh/docs/runtime/env)
|
||||
- [Bun APIs](https://bun.sh/docs/runtime/bun-apis)
|
||||
- [Web APIs](https://bun.sh/docs/runtime/web-apis)
|
||||
- [Node.js compatibility](https://bun.sh/docs/runtime/nodejs-apis)
|
||||
- [Single-file executable](https://bun.sh/docs/bundler/executables)
|
||||
- [Plugins](https://bun.sh/docs/runtime/plugins)
|
||||
- [Watch mode / Hot Reloading](https://bun.sh/docs/runtime/hot)
|
||||
- [Module resolution](https://bun.sh/docs/runtime/modules)
|
||||
- [Auto-install](https://bun.sh/docs/runtime/autoimport)
|
||||
- [bunfig.toml](https://bun.sh/docs/runtime/bunfig)
|
||||
- [Debugger](https://bun.sh/docs/runtime/debugger)
|
||||
- [$ Shell](https://bun.sh/docs/runtime/shell)
|
||||
- [`bun run`](https://bun.com/docs/cli/run)
|
||||
- [File types (Loaders)](https://bun.com/docs/runtime/loaders)
|
||||
- [TypeScript](https://bun.com/docs/runtime/typescript)
|
||||
- [JSX](https://bun.com/docs/runtime/jsx)
|
||||
- [Environment variables](https://bun.com/docs/runtime/env)
|
||||
- [Bun APIs](https://bun.com/docs/runtime/bun-apis)
|
||||
- [Web APIs](https://bun.com/docs/runtime/web-apis)
|
||||
- [Node.js compatibility](https://bun.com/docs/runtime/nodejs-apis)
|
||||
- [Single-file executable](https://bun.com/docs/bundler/executables)
|
||||
- [Plugins](https://bun.com/docs/runtime/plugins)
|
||||
- [Watch mode / Hot Reloading](https://bun.com/docs/runtime/hot)
|
||||
- [Module resolution](https://bun.com/docs/runtime/modules)
|
||||
- [Auto-install](https://bun.com/docs/runtime/autoimport)
|
||||
- [bunfig.toml](https://bun.com/docs/runtime/bunfig)
|
||||
- [Debugger](https://bun.com/docs/runtime/debugger)
|
||||
- [$ Shell](https://bun.com/docs/runtime/shell)
|
||||
|
||||
- Package manager
|
||||
|
||||
- [`bun install`](https://bun.sh/docs/cli/install)
|
||||
- [`bun add`](https://bun.sh/docs/cli/add)
|
||||
- [`bun remove`](https://bun.sh/docs/cli/remove)
|
||||
- [`bun update`](https://bun.sh/docs/cli/update)
|
||||
- [`bun link`](https://bun.sh/docs/cli/link)
|
||||
- [`bun unlink`](https://bun.sh/docs/cli/unlink)
|
||||
- [`bun pm`](https://bun.sh/docs/cli/pm)
|
||||
- [`bun outdated`](https://bun.sh/docs/cli/outdated)
|
||||
- [`bun publish`](https://bun.sh/docs/cli/publish)
|
||||
- [`bun patch`](https://bun.sh/docs/install/patch)
|
||||
- [`bun patch-commit`](https://bun.sh/docs/cli/patch-commit)
|
||||
- [Global cache](https://bun.sh/docs/install/cache)
|
||||
- [Workspaces](https://bun.sh/docs/install/workspaces)
|
||||
- [Lifecycle scripts](https://bun.sh/docs/install/lifecycle)
|
||||
- [Filter](https://bun.sh/docs/cli/filter)
|
||||
- [Lockfile](https://bun.sh/docs/install/lockfile)
|
||||
- [Scopes and registries](https://bun.sh/docs/install/registries)
|
||||
- [Overrides and resolutions](https://bun.sh/docs/install/overrides)
|
||||
- [`.npmrc`](https://bun.sh/docs/install/npmrc)
|
||||
- [`bun install`](https://bun.com/docs/cli/install)
|
||||
- [`bun add`](https://bun.com/docs/cli/add)
|
||||
- [`bun remove`](https://bun.com/docs/cli/remove)
|
||||
- [`bun update`](https://bun.com/docs/cli/update)
|
||||
- [`bun link`](https://bun.com/docs/cli/link)
|
||||
- [`bun unlink`](https://bun.com/docs/cli/unlink)
|
||||
- [`bun pm`](https://bun.com/docs/cli/pm)
|
||||
- [`bun outdated`](https://bun.com/docs/cli/outdated)
|
||||
- [`bun publish`](https://bun.com/docs/cli/publish)
|
||||
- [`bun patch`](https://bun.com/docs/install/patch)
|
||||
- [`bun patch-commit`](https://bun.com/docs/cli/patch-commit)
|
||||
- [Global cache](https://bun.com/docs/install/cache)
|
||||
- [Workspaces](https://bun.com/docs/install/workspaces)
|
||||
- [Lifecycle scripts](https://bun.com/docs/install/lifecycle)
|
||||
- [Filter](https://bun.com/docs/cli/filter)
|
||||
- [Lockfile](https://bun.com/docs/install/lockfile)
|
||||
- [Scopes and registries](https://bun.com/docs/install/registries)
|
||||
- [Overrides and resolutions](https://bun.com/docs/install/overrides)
|
||||
- [`.npmrc`](https://bun.com/docs/install/npmrc)
|
||||
|
||||
- Bundler
|
||||
|
||||
- [`Bun.build`](https://bun.sh/docs/bundler)
|
||||
- [Loaders](https://bun.sh/docs/bundler/loaders)
|
||||
- [Plugins](https://bun.sh/docs/bundler/plugins)
|
||||
- [Macros](https://bun.sh/docs/bundler/macros)
|
||||
- [vs esbuild](https://bun.sh/docs/bundler/vs-esbuild)
|
||||
- [Single-file executable](https://bun.sh/docs/bundler/executables)
|
||||
- [CSS](https://bun.sh/docs/bundler/css)
|
||||
- [HTML](https://bun.sh/docs/bundler/html)
|
||||
- [Hot Module Replacement (HMR)](https://bun.sh/docs/bundler/hmr)
|
||||
- [Full-stack with HTML imports](https://bun.sh/docs/bundler/fullstack)
|
||||
- [`Bun.build`](https://bun.com/docs/bundler)
|
||||
- [Loaders](https://bun.com/docs/bundler/loaders)
|
||||
- [Plugins](https://bun.com/docs/bundler/plugins)
|
||||
- [Macros](https://bun.com/docs/bundler/macros)
|
||||
- [vs esbuild](https://bun.com/docs/bundler/vs-esbuild)
|
||||
- [Single-file executable](https://bun.com/docs/bundler/executables)
|
||||
- [CSS](https://bun.com/docs/bundler/css)
|
||||
- [HTML](https://bun.com/docs/bundler/html)
|
||||
- [Hot Module Replacement (HMR)](https://bun.com/docs/bundler/hmr)
|
||||
- [Full-stack with HTML imports](https://bun.com/docs/bundler/fullstack)
|
||||
|
||||
- Test runner
|
||||
|
||||
- [`bun test`](https://bun.sh/docs/cli/test)
|
||||
- [Writing tests](https://bun.sh/docs/test/writing)
|
||||
- [Watch mode](https://bun.sh/docs/test/hot)
|
||||
- [Lifecycle hooks](https://bun.sh/docs/test/lifecycle)
|
||||
- [Mocks](https://bun.sh/docs/test/mocks)
|
||||
- [Snapshots](https://bun.sh/docs/test/snapshots)
|
||||
- [Dates and times](https://bun.sh/docs/test/time)
|
||||
- [DOM testing](https://bun.sh/docs/test/dom)
|
||||
- [Code coverage](https://bun.sh/docs/test/coverage)
|
||||
- [Configuration](https://bun.sh/docs/test/configuration)
|
||||
- [Discovery](https://bun.sh/docs/test/discovery)
|
||||
- [Reporters](https://bun.sh/docs/test/reporters)
|
||||
- [Runtime Behavior](https://bun.sh/docs/test/runtime-behavior)
|
||||
- [`bun test`](https://bun.com/docs/cli/test)
|
||||
- [Writing tests](https://bun.com/docs/test/writing)
|
||||
- [Watch mode](https://bun.com/docs/test/hot)
|
||||
- [Lifecycle hooks](https://bun.com/docs/test/lifecycle)
|
||||
- [Mocks](https://bun.com/docs/test/mocks)
|
||||
- [Snapshots](https://bun.com/docs/test/snapshots)
|
||||
- [Dates and times](https://bun.com/docs/test/time)
|
||||
- [DOM testing](https://bun.com/docs/test/dom)
|
||||
- [Code coverage](https://bun.com/docs/test/coverage)
|
||||
- [Configuration](https://bun.com/docs/test/configuration)
|
||||
- [Discovery](https://bun.com/docs/test/discovery)
|
||||
- [Reporters](https://bun.com/docs/test/reporters)
|
||||
- [Runtime Behavior](https://bun.com/docs/test/runtime-behavior)
|
||||
|
||||
- Package runner
|
||||
|
||||
- [`bunx`](https://bun.sh/docs/cli/bunx)
|
||||
- [`bunx`](https://bun.com/docs/cli/bunx)
|
||||
|
||||
- API
|
||||
|
||||
- [HTTP server (`Bun.serve`)](https://bun.sh/docs/api/http)
|
||||
- [WebSockets](https://bun.sh/docs/api/websockets)
|
||||
- [Workers](https://bun.sh/docs/api/workers)
|
||||
- [Binary data](https://bun.sh/docs/api/binary-data)
|
||||
- [Streams](https://bun.sh/docs/api/streams)
|
||||
- [File I/O (`Bun.file`)](https://bun.sh/docs/api/file-io)
|
||||
- [import.meta](https://bun.sh/docs/api/import-meta)
|
||||
- [SQLite (`bun:sqlite`)](https://bun.sh/docs/api/sqlite)
|
||||
- [PostgreSQL (`Bun.sql`)](https://bun.sh/docs/api/sql)
|
||||
- [Redis (`Bun.redis`)](https://bun.sh/docs/api/redis)
|
||||
- [S3 Client (`Bun.s3`)](https://bun.sh/docs/api/s3)
|
||||
- [FileSystemRouter](https://bun.sh/docs/api/file-system-router)
|
||||
- [TCP sockets](https://bun.sh/docs/api/tcp)
|
||||
- [UDP sockets](https://bun.sh/docs/api/udp)
|
||||
- [Globals](https://bun.sh/docs/api/globals)
|
||||
- [$ Shell](https://bun.sh/docs/runtime/shell)
|
||||
- [Child processes (spawn)](https://bun.sh/docs/api/spawn)
|
||||
- [Transpiler (`Bun.Transpiler`)](https://bun.sh/docs/api/transpiler)
|
||||
- [Hashing](https://bun.sh/docs/api/hashing)
|
||||
- [Colors (`Bun.color`)](https://bun.sh/docs/api/color)
|
||||
- [Console](https://bun.sh/docs/api/console)
|
||||
- [FFI (`bun:ffi`)](https://bun.sh/docs/api/ffi)
|
||||
- [C Compiler (`bun:ffi` cc)](https://bun.sh/docs/api/cc)
|
||||
- [HTMLRewriter](https://bun.sh/docs/api/html-rewriter)
|
||||
- [Testing (`bun:test`)](https://bun.sh/docs/api/test)
|
||||
- [Cookies (`Bun.Cookie`)](https://bun.sh/docs/api/cookie)
|
||||
- [Utils](https://bun.sh/docs/api/utils)
|
||||
- [Node-API](https://bun.sh/docs/api/node-api)
|
||||
- [Glob (`Bun.Glob`)](https://bun.sh/docs/api/glob)
|
||||
- [Semver (`Bun.semver`)](https://bun.sh/docs/api/semver)
|
||||
- [DNS](https://bun.sh/docs/api/dns)
|
||||
- [fetch API extensions](https://bun.sh/docs/api/fetch)
|
||||
- [HTTP server (`Bun.serve`)](https://bun.com/docs/api/http)
|
||||
- [WebSockets](https://bun.com/docs/api/websockets)
|
||||
- [Workers](https://bun.com/docs/api/workers)
|
||||
- [Binary data](https://bun.com/docs/api/binary-data)
|
||||
- [Streams](https://bun.com/docs/api/streams)
|
||||
- [File I/O (`Bun.file`)](https://bun.com/docs/api/file-io)
|
||||
- [import.meta](https://bun.com/docs/api/import-meta)
|
||||
- [SQLite (`bun:sqlite`)](https://bun.com/docs/api/sqlite)
|
||||
- [PostgreSQL (`Bun.sql`)](https://bun.com/docs/api/sql)
|
||||
- [Redis (`Bun.redis`)](https://bun.com/docs/api/redis)
|
||||
- [S3 Client (`Bun.s3`)](https://bun.com/docs/api/s3)
|
||||
- [FileSystemRouter](https://bun.com/docs/api/file-system-router)
|
||||
- [TCP sockets](https://bun.com/docs/api/tcp)
|
||||
- [UDP sockets](https://bun.com/docs/api/udp)
|
||||
- [Globals](https://bun.com/docs/api/globals)
|
||||
- [$ Shell](https://bun.com/docs/runtime/shell)
|
||||
- [Child processes (spawn)](https://bun.com/docs/api/spawn)
|
||||
- [Transpiler (`Bun.Transpiler`)](https://bun.com/docs/api/transpiler)
|
||||
- [Hashing](https://bun.com/docs/api/hashing)
|
||||
- [Colors (`Bun.color`)](https://bun.com/docs/api/color)
|
||||
- [Console](https://bun.com/docs/api/console)
|
||||
- [FFI (`bun:ffi`)](https://bun.com/docs/api/ffi)
|
||||
- [C Compiler (`bun:ffi` cc)](https://bun.com/docs/api/cc)
|
||||
- [HTMLRewriter](https://bun.com/docs/api/html-rewriter)
|
||||
- [Testing (`bun:test`)](https://bun.com/docs/api/test)
|
||||
- [Cookies (`Bun.Cookie`)](https://bun.com/docs/api/cookie)
|
||||
- [Utils](https://bun.com/docs/api/utils)
|
||||
- [Node-API](https://bun.com/docs/api/node-api)
|
||||
- [Glob (`Bun.Glob`)](https://bun.com/docs/api/glob)
|
||||
- [Semver (`Bun.semver`)](https://bun.com/docs/api/semver)
|
||||
- [DNS](https://bun.com/docs/api/dns)
|
||||
- [fetch API extensions](https://bun.com/docs/api/fetch)
|
||||
|
||||
## Guides
|
||||
|
||||
- Binary
|
||||
|
||||
- [Convert a Blob to a string](https://bun.sh/guides/binary/blob-to-string)
|
||||
- [Convert a Buffer to a blob](https://bun.sh/guides/binary/buffer-to-blob)
|
||||
- [Convert a Blob to a DataView](https://bun.sh/guides/binary/blob-to-dataview)
|
||||
- [Convert a Buffer to a string](https://bun.sh/guides/binary/buffer-to-string)
|
||||
- [Convert a Blob to a ReadableStream](https://bun.sh/guides/binary/blob-to-stream)
|
||||
- [Convert a Blob to a Uint8Array](https://bun.sh/guides/binary/blob-to-typedarray)
|
||||
- [Convert a DataView to a string](https://bun.sh/guides/binary/dataview-to-string)
|
||||
- [Convert a Uint8Array to a Blob](https://bun.sh/guides/binary/typedarray-to-blob)
|
||||
- [Convert a Blob to an ArrayBuffer](https://bun.sh/guides/binary/blob-to-arraybuffer)
|
||||
- [Convert an ArrayBuffer to a Blob](https://bun.sh/guides/binary/arraybuffer-to-blob)
|
||||
- [Convert a Buffer to a Uint8Array](https://bun.sh/guides/binary/buffer-to-typedarray)
|
||||
- [Convert a Uint8Array to a Buffer](https://bun.sh/guides/binary/typedarray-to-buffer)
|
||||
- [Convert a Uint8Array to a string](https://bun.sh/guides/binary/typedarray-to-string)
|
||||
- [Convert a Buffer to an ArrayBuffer](https://bun.sh/guides/binary/buffer-to-arraybuffer)
|
||||
- [Convert an ArrayBuffer to a Buffer](https://bun.sh/guides/binary/arraybuffer-to-buffer)
|
||||
- [Convert an ArrayBuffer to a string](https://bun.sh/guides/binary/arraybuffer-to-string)
|
||||
- [Convert a Uint8Array to a DataView](https://bun.sh/guides/binary/typedarray-to-dataview)
|
||||
- [Convert a Buffer to a ReadableStream](https://bun.sh/guides/binary/buffer-to-readablestream)
|
||||
- [Convert a Uint8Array to an ArrayBuffer](https://bun.sh/guides/binary/typedarray-to-arraybuffer)
|
||||
- [Convert an ArrayBuffer to a Uint8Array](https://bun.sh/guides/binary/arraybuffer-to-typedarray)
|
||||
- [Convert an ArrayBuffer to an array of numbers](https://bun.sh/guides/binary/arraybuffer-to-array)
|
||||
- [Convert a Uint8Array to a ReadableStream](https://bun.sh/guides/binary/typedarray-to-readablestream)
|
||||
- [Convert a Blob to a string](https://bun.com/guides/binary/blob-to-string)
|
||||
- [Convert a Buffer to a blob](https://bun.com/guides/binary/buffer-to-blob)
|
||||
- [Convert a Blob to a DataView](https://bun.com/guides/binary/blob-to-dataview)
|
||||
- [Convert a Buffer to a string](https://bun.com/guides/binary/buffer-to-string)
|
||||
- [Convert a Blob to a ReadableStream](https://bun.com/guides/binary/blob-to-stream)
|
||||
- [Convert a Blob to a Uint8Array](https://bun.com/guides/binary/blob-to-typedarray)
|
||||
- [Convert a DataView to a string](https://bun.com/guides/binary/dataview-to-string)
|
||||
- [Convert a Uint8Array to a Blob](https://bun.com/guides/binary/typedarray-to-blob)
|
||||
- [Convert a Blob to an ArrayBuffer](https://bun.com/guides/binary/blob-to-arraybuffer)
|
||||
- [Convert an ArrayBuffer to a Blob](https://bun.com/guides/binary/arraybuffer-to-blob)
|
||||
- [Convert a Buffer to a Uint8Array](https://bun.com/guides/binary/buffer-to-typedarray)
|
||||
- [Convert a Uint8Array to a Buffer](https://bun.com/guides/binary/typedarray-to-buffer)
|
||||
- [Convert a Uint8Array to a string](https://bun.com/guides/binary/typedarray-to-string)
|
||||
- [Convert a Buffer to an ArrayBuffer](https://bun.com/guides/binary/buffer-to-arraybuffer)
|
||||
- [Convert an ArrayBuffer to a Buffer](https://bun.com/guides/binary/arraybuffer-to-buffer)
|
||||
- [Convert an ArrayBuffer to a string](https://bun.com/guides/binary/arraybuffer-to-string)
|
||||
- [Convert a Uint8Array to a DataView](https://bun.com/guides/binary/typedarray-to-dataview)
|
||||
- [Convert a Buffer to a ReadableStream](https://bun.com/guides/binary/buffer-to-readablestream)
|
||||
- [Convert a Uint8Array to an ArrayBuffer](https://bun.com/guides/binary/typedarray-to-arraybuffer)
|
||||
- [Convert an ArrayBuffer to a Uint8Array](https://bun.com/guides/binary/arraybuffer-to-typedarray)
|
||||
- [Convert an ArrayBuffer to an array of numbers](https://bun.com/guides/binary/arraybuffer-to-array)
|
||||
- [Convert a Uint8Array to a ReadableStream](https://bun.com/guides/binary/typedarray-to-readablestream)
|
||||
|
||||
- Ecosystem
|
||||
|
||||
- [Use React and JSX](https://bun.sh/guides/ecosystem/react)
|
||||
- [Use EdgeDB with Bun](https://bun.sh/guides/ecosystem/edgedb)
|
||||
- [Use Prisma with Bun](https://bun.sh/guides/ecosystem/prisma)
|
||||
- [Add Sentry to a Bun app](https://bun.sh/guides/ecosystem/sentry)
|
||||
- [Create a Discord bot](https://bun.sh/guides/ecosystem/discordjs)
|
||||
- [Run Bun as a daemon with PM2](https://bun.sh/guides/ecosystem/pm2)
|
||||
- [Use Drizzle ORM with Bun](https://bun.sh/guides/ecosystem/drizzle)
|
||||
- [Build an app with Nuxt and Bun](https://bun.sh/guides/ecosystem/nuxt)
|
||||
- [Build an app with Qwik and Bun](https://bun.sh/guides/ecosystem/qwik)
|
||||
- [Build an app with Astro and Bun](https://bun.sh/guides/ecosystem/astro)
|
||||
- [Build an app with Remix and Bun](https://bun.sh/guides/ecosystem/remix)
|
||||
- [Build a frontend using Vite and Bun](https://bun.sh/guides/ecosystem/vite)
|
||||
- [Build an app with Next.js and Bun](https://bun.sh/guides/ecosystem/nextjs)
|
||||
- [Run Bun as a daemon with systemd](https://bun.sh/guides/ecosystem/systemd)
|
||||
- [Deploy a Bun application on Render](https://bun.sh/guides/ecosystem/render)
|
||||
- [Build an HTTP server using Hono and Bun](https://bun.sh/guides/ecosystem/hono)
|
||||
- [Build an app with SvelteKit and Bun](https://bun.sh/guides/ecosystem/sveltekit)
|
||||
- [Build an app with SolidStart and Bun](https://bun.sh/guides/ecosystem/solidstart)
|
||||
- [Build an HTTP server using Elysia and Bun](https://bun.sh/guides/ecosystem/elysia)
|
||||
- [Build an HTTP server using StricJS and Bun](https://bun.sh/guides/ecosystem/stric)
|
||||
- [Containerize a Bun application with Docker](https://bun.sh/guides/ecosystem/docker)
|
||||
- [Build an HTTP server using Express and Bun](https://bun.sh/guides/ecosystem/express)
|
||||
- [Use Neon Postgres through Drizzle ORM](https://bun.sh/guides/ecosystem/neon-drizzle)
|
||||
- [Server-side render (SSR) a React component](https://bun.sh/guides/ecosystem/ssr-react)
|
||||
- [Read and write data to MongoDB using Mongoose and Bun](https://bun.sh/guides/ecosystem/mongoose)
|
||||
- [Use Neon's Serverless Postgres with Bun](https://bun.sh/guides/ecosystem/neon-serverless-postgres)
|
||||
- [Use React and JSX](https://bun.com/guides/ecosystem/react)
|
||||
- [Use EdgeDB with Bun](https://bun.com/guides/ecosystem/edgedb)
|
||||
- [Use Prisma with Bun](https://bun.com/guides/ecosystem/prisma)
|
||||
- [Add Sentry to a Bun app](https://bun.com/guides/ecosystem/sentry)
|
||||
- [Create a Discord bot](https://bun.com/guides/ecosystem/discordjs)
|
||||
- [Run Bun as a daemon with PM2](https://bun.com/guides/ecosystem/pm2)
|
||||
- [Use Drizzle ORM with Bun](https://bun.com/guides/ecosystem/drizzle)
|
||||
- [Build an app with Nuxt and Bun](https://bun.com/guides/ecosystem/nuxt)
|
||||
- [Build an app with Qwik and Bun](https://bun.com/guides/ecosystem/qwik)
|
||||
- [Build an app with Astro and Bun](https://bun.com/guides/ecosystem/astro)
|
||||
- [Build an app with Remix and Bun](https://bun.com/guides/ecosystem/remix)
|
||||
- [Build a frontend using Vite and Bun](https://bun.com/guides/ecosystem/vite)
|
||||
- [Build an app with Next.js and Bun](https://bun.com/guides/ecosystem/nextjs)
|
||||
- [Run Bun as a daemon with systemd](https://bun.com/guides/ecosystem/systemd)
|
||||
- [Deploy a Bun application on Render](https://bun.com/guides/ecosystem/render)
|
||||
- [Build an HTTP server using Hono and Bun](https://bun.com/guides/ecosystem/hono)
|
||||
- [Build an app with SvelteKit and Bun](https://bun.com/guides/ecosystem/sveltekit)
|
||||
- [Build an app with SolidStart and Bun](https://bun.com/guides/ecosystem/solidstart)
|
||||
- [Build an HTTP server using Elysia and Bun](https://bun.com/guides/ecosystem/elysia)
|
||||
- [Build an HTTP server using StricJS and Bun](https://bun.com/guides/ecosystem/stric)
|
||||
- [Containerize a Bun application with Docker](https://bun.com/guides/ecosystem/docker)
|
||||
- [Build an HTTP server using Express and Bun](https://bun.com/guides/ecosystem/express)
|
||||
- [Use Neon Postgres through Drizzle ORM](https://bun.com/guides/ecosystem/neon-drizzle)
|
||||
- [Server-side render (SSR) a React component](https://bun.com/guides/ecosystem/ssr-react)
|
||||
- [Read and write data to MongoDB using Mongoose and Bun](https://bun.com/guides/ecosystem/mongoose)
|
||||
- [Use Neon's Serverless Postgres with Bun](https://bun.com/guides/ecosystem/neon-serverless-postgres)
|
||||
|
||||
- HTMLRewriter
|
||||
|
||||
- [Extract links from a webpage using HTMLRewriter](https://bun.sh/guides/html-rewriter/extract-links)
|
||||
- [Extract social share images and Open Graph tags](https://bun.sh/guides/html-rewriter/extract-social-meta)
|
||||
- [Extract links from a webpage using HTMLRewriter](https://bun.com/guides/html-rewriter/extract-links)
|
||||
- [Extract social share images and Open Graph tags](https://bun.com/guides/html-rewriter/extract-social-meta)
|
||||
|
||||
- HTTP
|
||||
|
||||
- [Hot reload an HTTP server](https://bun.sh/guides/http/hot)
|
||||
- [Common HTTP server usage](https://bun.sh/guides/http/server)
|
||||
- [Write a simple HTTP server](https://bun.sh/guides/http/simple)
|
||||
- [Configure TLS on an HTTP server](https://bun.sh/guides/http/tls)
|
||||
- [Send an HTTP request using fetch](https://bun.sh/guides/http/fetch)
|
||||
- [Proxy HTTP requests using fetch()](https://bun.sh/guides/http/proxy)
|
||||
- [Start a cluster of HTTP servers](https://bun.sh/guides/http/cluster)
|
||||
- [Stream a file as an HTTP Response](https://bun.sh/guides/http/stream-file)
|
||||
- [fetch with unix domain sockets in Bun](https://bun.sh/guides/http/fetch-unix)
|
||||
- [Upload files via HTTP using FormData](https://bun.sh/guides/http/file-uploads)
|
||||
- [Streaming HTTP Server with Async Iterators](https://bun.sh/guides/http/stream-iterator)
|
||||
- [Streaming HTTP Server with Node.js Streams](https://bun.sh/guides/http/stream-node-streams-in-bun)
|
||||
- [Hot reload an HTTP server](https://bun.com/guides/http/hot)
|
||||
- [Common HTTP server usage](https://bun.com/guides/http/server)
|
||||
- [Write a simple HTTP server](https://bun.com/guides/http/simple)
|
||||
- [Configure TLS on an HTTP server](https://bun.com/guides/http/tls)
|
||||
- [Send an HTTP request using fetch](https://bun.com/guides/http/fetch)
|
||||
- [Proxy HTTP requests using fetch()](https://bun.com/guides/http/proxy)
|
||||
- [Start a cluster of HTTP servers](https://bun.com/guides/http/cluster)
|
||||
- [Stream a file as an HTTP Response](https://bun.com/guides/http/stream-file)
|
||||
- [fetch with unix domain sockets in Bun](https://bun.com/guides/http/fetch-unix)
|
||||
- [Upload files via HTTP using FormData](https://bun.com/guides/http/file-uploads)
|
||||
- [Streaming HTTP Server with Async Iterators](https://bun.com/guides/http/stream-iterator)
|
||||
- [Streaming HTTP Server with Node.js Streams](https://bun.com/guides/http/stream-node-streams-in-bun)
|
||||
|
||||
- Install
|
||||
|
||||
- [Add a dependency](https://bun.sh/guides/install/add)
|
||||
- [Add a Git dependency](https://bun.sh/guides/install/add-git)
|
||||
- [Add a peer dependency](https://bun.sh/guides/install/add-peer)
|
||||
- [Add a trusted dependency](https://bun.sh/guides/install/trusted)
|
||||
- [Add a development dependency](https://bun.sh/guides/install/add-dev)
|
||||
- [Add a tarball dependency](https://bun.sh/guides/install/add-tarball)
|
||||
- [Add an optional dependency](https://bun.sh/guides/install/add-optional)
|
||||
- [Generate a yarn-compatible lockfile](https://bun.sh/guides/install/yarnlock)
|
||||
- [Configuring a monorepo using workspaces](https://bun.sh/guides/install/workspaces)
|
||||
- [Install a package under a different name](https://bun.sh/guides/install/npm-alias)
|
||||
- [Install dependencies with Bun in GitHub Actions](https://bun.sh/guides/install/cicd)
|
||||
- [Using bun install with Artifactory](https://bun.sh/guides/install/jfrog-artifactory)
|
||||
- [Configure git to diff Bun's lockb lockfile](https://bun.sh/guides/install/git-diff-bun-lockfile)
|
||||
- [Override the default npm registry for bun install](https://bun.sh/guides/install/custom-registry)
|
||||
- [Using bun install with an Azure Artifacts npm registry](https://bun.sh/guides/install/azure-artifacts)
|
||||
- [Migrate from npm install to bun install](https://bun.sh/guides/install/from-npm-install-to-bun-install)
|
||||
- [Configure a private registry for an organization scope with bun install](https://bun.sh/guides/install/registry-scope)
|
||||
- [Add a dependency](https://bun.com/guides/install/add)
|
||||
- [Add a Git dependency](https://bun.com/guides/install/add-git)
|
||||
- [Add a peer dependency](https://bun.com/guides/install/add-peer)
|
||||
- [Add a trusted dependency](https://bun.com/guides/install/trusted)
|
||||
- [Add a development dependency](https://bun.com/guides/install/add-dev)
|
||||
- [Add a tarball dependency](https://bun.com/guides/install/add-tarball)
|
||||
- [Add an optional dependency](https://bun.com/guides/install/add-optional)
|
||||
- [Generate a yarn-compatible lockfile](https://bun.com/guides/install/yarnlock)
|
||||
- [Configuring a monorepo using workspaces](https://bun.com/guides/install/workspaces)
|
||||
- [Install a package under a different name](https://bun.com/guides/install/npm-alias)
|
||||
- [Install dependencies with Bun in GitHub Actions](https://bun.com/guides/install/cicd)
|
||||
- [Using bun install with Artifactory](https://bun.com/guides/install/jfrog-artifactory)
|
||||
- [Configure git to diff Bun's lockb lockfile](https://bun.com/guides/install/git-diff-bun-lockfile)
|
||||
- [Override the default npm registry for bun install](https://bun.com/guides/install/custom-registry)
|
||||
- [Using bun install with an Azure Artifacts npm registry](https://bun.com/guides/install/azure-artifacts)
|
||||
- [Migrate from npm install to bun install](https://bun.com/guides/install/from-npm-install-to-bun-install)
|
||||
- [Configure a private registry for an organization scope with bun install](https://bun.com/guides/install/registry-scope)
|
||||
|
||||
- Process
|
||||
|
||||
- [Read from stdin](https://bun.sh/guides/process/stdin)
|
||||
- [Listen for CTRL+C](https://bun.sh/guides/process/ctrl-c)
|
||||
- [Spawn a child process](https://bun.sh/guides/process/spawn)
|
||||
- [Listen to OS signals](https://bun.sh/guides/process/os-signals)
|
||||
- [Parse command-line arguments](https://bun.sh/guides/process/argv)
|
||||
- [Read stderr from a child process](https://bun.sh/guides/process/spawn-stderr)
|
||||
- [Read stdout from a child process](https://bun.sh/guides/process/spawn-stdout)
|
||||
- [Get the process uptime in nanoseconds](https://bun.sh/guides/process/nanoseconds)
|
||||
- [Spawn a child process and communicate using IPC](https://bun.sh/guides/process/ipc)
|
||||
- [Read from stdin](https://bun.com/guides/process/stdin)
|
||||
- [Listen for CTRL+C](https://bun.com/guides/process/ctrl-c)
|
||||
- [Spawn a child process](https://bun.com/guides/process/spawn)
|
||||
- [Listen to OS signals](https://bun.com/guides/process/os-signals)
|
||||
- [Parse command-line arguments](https://bun.com/guides/process/argv)
|
||||
- [Read stderr from a child process](https://bun.com/guides/process/spawn-stderr)
|
||||
- [Read stdout from a child process](https://bun.com/guides/process/spawn-stdout)
|
||||
- [Get the process uptime in nanoseconds](https://bun.com/guides/process/nanoseconds)
|
||||
- [Spawn a child process and communicate using IPC](https://bun.com/guides/process/ipc)
|
||||
|
||||
- Read file
|
||||
|
||||
- [Read a JSON file](https://bun.sh/guides/read-file/json)
|
||||
- [Check if a file exists](https://bun.sh/guides/read-file/exists)
|
||||
- [Read a file as a string](https://bun.sh/guides/read-file/string)
|
||||
- [Read a file to a Buffer](https://bun.sh/guides/read-file/buffer)
|
||||
- [Get the MIME type of a file](https://bun.sh/guides/read-file/mime)
|
||||
- [Watch a directory for changes](https://bun.sh/guides/read-file/watch)
|
||||
- [Read a file as a ReadableStream](https://bun.sh/guides/read-file/stream)
|
||||
- [Read a file to a Uint8Array](https://bun.sh/guides/read-file/uint8array)
|
||||
- [Read a file to an ArrayBuffer](https://bun.sh/guides/read-file/arraybuffer)
|
||||
- [Read a JSON file](https://bun.com/guides/read-file/json)
|
||||
- [Check if a file exists](https://bun.com/guides/read-file/exists)
|
||||
- [Read a file as a string](https://bun.com/guides/read-file/string)
|
||||
- [Read a file to a Buffer](https://bun.com/guides/read-file/buffer)
|
||||
- [Get the MIME type of a file](https://bun.com/guides/read-file/mime)
|
||||
- [Watch a directory for changes](https://bun.com/guides/read-file/watch)
|
||||
- [Read a file as a ReadableStream](https://bun.com/guides/read-file/stream)
|
||||
- [Read a file to a Uint8Array](https://bun.com/guides/read-file/uint8array)
|
||||
- [Read a file to an ArrayBuffer](https://bun.com/guides/read-file/arraybuffer)
|
||||
|
||||
- Runtime
|
||||
|
||||
- [Delete files](https://bun.sh/guides/runtime/delete-file)
|
||||
- [Run a Shell Command](https://bun.sh/guides/runtime/shell)
|
||||
- [Import a JSON file](https://bun.sh/guides/runtime/import-json)
|
||||
- [Import a TOML file](https://bun.sh/guides/runtime/import-toml)
|
||||
- [Set a time zone in Bun](https://bun.sh/guides/runtime/timezone)
|
||||
- [Set environment variables](https://bun.sh/guides/runtime/set-env)
|
||||
- [Re-map import paths](https://bun.sh/guides/runtime/tsconfig-paths)
|
||||
- [Delete directories](https://bun.sh/guides/runtime/delete-directory)
|
||||
- [Read environment variables](https://bun.sh/guides/runtime/read-env)
|
||||
- [Import a HTML file as text](https://bun.sh/guides/runtime/import-html)
|
||||
- [Install and run Bun in GitHub Actions](https://bun.sh/guides/runtime/cicd)
|
||||
- [Debugging Bun with the web debugger](https://bun.sh/guides/runtime/web-debugger)
|
||||
- [Install TypeScript declarations for Bun](https://bun.sh/guides/runtime/typescript)
|
||||
- [Debugging Bun with the VS Code extension](https://bun.sh/guides/runtime/vscode-debugger)
|
||||
- [Inspect memory usage using V8 heap snapshots](https://bun.sh/guides/runtime/heap-snapshot)
|
||||
- [Define and replace static globals & constants](https://bun.sh/guides/runtime/define-constant)
|
||||
- [Codesign a single-file JavaScript executable on macOS](https://bun.sh/guides/runtime/codesign-macos-executable)
|
||||
- [Delete files](https://bun.com/guides/runtime/delete-file)
|
||||
- [Run a Shell Command](https://bun.com/guides/runtime/shell)
|
||||
- [Import a JSON file](https://bun.com/guides/runtime/import-json)
|
||||
- [Import a TOML file](https://bun.com/guides/runtime/import-toml)
|
||||
- [Set a time zone in Bun](https://bun.com/guides/runtime/timezone)
|
||||
- [Set environment variables](https://bun.com/guides/runtime/set-env)
|
||||
- [Re-map import paths](https://bun.com/guides/runtime/tsconfig-paths)
|
||||
- [Delete directories](https://bun.com/guides/runtime/delete-directory)
|
||||
- [Read environment variables](https://bun.com/guides/runtime/read-env)
|
||||
- [Import a HTML file as text](https://bun.com/guides/runtime/import-html)
|
||||
- [Install and run Bun in GitHub Actions](https://bun.com/guides/runtime/cicd)
|
||||
- [Debugging Bun with the web debugger](https://bun.com/guides/runtime/web-debugger)
|
||||
- [Install TypeScript declarations for Bun](https://bun.com/guides/runtime/typescript)
|
||||
- [Debugging Bun with the VS Code extension](https://bun.com/guides/runtime/vscode-debugger)
|
||||
- [Inspect memory usage using V8 heap snapshots](https://bun.com/guides/runtime/heap-snapshot)
|
||||
- [Define and replace static globals & constants](https://bun.com/guides/runtime/define-constant)
|
||||
- [Codesign a single-file JavaScript executable on macOS](https://bun.com/guides/runtime/codesign-macos-executable)
|
||||
|
||||
- Streams
|
||||
|
||||
- [Convert a ReadableStream to JSON](https://bun.sh/guides/streams/to-json)
|
||||
- [Convert a ReadableStream to a Blob](https://bun.sh/guides/streams/to-blob)
|
||||
- [Convert a ReadableStream to a Buffer](https://bun.sh/guides/streams/to-buffer)
|
||||
- [Convert a ReadableStream to a string](https://bun.sh/guides/streams/to-string)
|
||||
- [Convert a ReadableStream to a Uint8Array](https://bun.sh/guides/streams/to-typedarray)
|
||||
- [Convert a ReadableStream to an array of chunks](https://bun.sh/guides/streams/to-array)
|
||||
- [Convert a Node.js Readable to JSON](https://bun.sh/guides/streams/node-readable-to-json)
|
||||
- [Convert a ReadableStream to an ArrayBuffer](https://bun.sh/guides/streams/to-arraybuffer)
|
||||
- [Convert a Node.js Readable to a Blob](https://bun.sh/guides/streams/node-readable-to-blob)
|
||||
- [Convert a Node.js Readable to a string](https://bun.sh/guides/streams/node-readable-to-string)
|
||||
- [Convert a Node.js Readable to an Uint8Array](https://bun.sh/guides/streams/node-readable-to-uint8array)
|
||||
- [Convert a Node.js Readable to an ArrayBuffer](https://bun.sh/guides/streams/node-readable-to-arraybuffer)
|
||||
- [Convert a ReadableStream to JSON](https://bun.com/guides/streams/to-json)
|
||||
- [Convert a ReadableStream to a Blob](https://bun.com/guides/streams/to-blob)
|
||||
- [Convert a ReadableStream to a Buffer](https://bun.com/guides/streams/to-buffer)
|
||||
- [Convert a ReadableStream to a string](https://bun.com/guides/streams/to-string)
|
||||
- [Convert a ReadableStream to a Uint8Array](https://bun.com/guides/streams/to-typedarray)
|
||||
- [Convert a ReadableStream to an array of chunks](https://bun.com/guides/streams/to-array)
|
||||
- [Convert a Node.js Readable to JSON](https://bun.com/guides/streams/node-readable-to-json)
|
||||
- [Convert a ReadableStream to an ArrayBuffer](https://bun.com/guides/streams/to-arraybuffer)
|
||||
- [Convert a Node.js Readable to a Blob](https://bun.com/guides/streams/node-readable-to-blob)
|
||||
- [Convert a Node.js Readable to a string](https://bun.com/guides/streams/node-readable-to-string)
|
||||
- [Convert a Node.js Readable to an Uint8Array](https://bun.com/guides/streams/node-readable-to-uint8array)
|
||||
- [Convert a Node.js Readable to an ArrayBuffer](https://bun.com/guides/streams/node-readable-to-arraybuffer)
|
||||
|
||||
- Test
|
||||
|
||||
- [Spy on methods in `bun test`](https://bun.sh/guides/test/spy-on)
|
||||
- [Bail early with the Bun test runner](https://bun.sh/guides/test/bail)
|
||||
- [Mock functions in `bun test`](https://bun.sh/guides/test/mock-functions)
|
||||
- [Run tests in watch mode with Bun](https://bun.sh/guides/test/watch-mode)
|
||||
- [Use snapshot testing in `bun test`](https://bun.sh/guides/test/snapshot)
|
||||
- [Skip tests with the Bun test runner](https://bun.sh/guides/test/skip-tests)
|
||||
- [Using Testing Library with Bun](https://bun.sh/guides/test/testing-library)
|
||||
- [Update snapshots in `bun test`](https://bun.sh/guides/test/update-snapshots)
|
||||
- [Run your tests with the Bun test runner](https://bun.sh/guides/test/run-tests)
|
||||
- [Set the system time in Bun's test runner](https://bun.sh/guides/test/mock-clock)
|
||||
- [Set a per-test timeout with the Bun test runner](https://bun.sh/guides/test/timeout)
|
||||
- [Migrate from Jest to Bun's test runner](https://bun.sh/guides/test/migrate-from-jest)
|
||||
- [Write browser DOM tests with Bun and happy-dom](https://bun.sh/guides/test/happy-dom)
|
||||
- [Mark a test as a "todo" with the Bun test runner](https://bun.sh/guides/test/todo-tests)
|
||||
- [Re-run tests multiple times with the Bun test runner](https://bun.sh/guides/test/rerun-each)
|
||||
- [Generate code coverage reports with the Bun test runner](https://bun.sh/guides/test/coverage)
|
||||
- [import, require, and test Svelte components with bun test](https://bun.sh/guides/test/svelte-test)
|
||||
- [Set a code coverage threshold with the Bun test runner](https://bun.sh/guides/test/coverage-threshold)
|
||||
- [Spy on methods in `bun test`](https://bun.com/guides/test/spy-on)
|
||||
- [Bail early with the Bun test runner](https://bun.com/guides/test/bail)
|
||||
- [Mock functions in `bun test`](https://bun.com/guides/test/mock-functions)
|
||||
- [Run tests in watch mode with Bun](https://bun.com/guides/test/watch-mode)
|
||||
- [Use snapshot testing in `bun test`](https://bun.com/guides/test/snapshot)
|
||||
- [Skip tests with the Bun test runner](https://bun.com/guides/test/skip-tests)
|
||||
- [Using Testing Library with Bun](https://bun.com/guides/test/testing-library)
|
||||
- [Update snapshots in `bun test`](https://bun.com/guides/test/update-snapshots)
|
||||
- [Run your tests with the Bun test runner](https://bun.com/guides/test/run-tests)
|
||||
- [Set the system time in Bun's test runner](https://bun.com/guides/test/mock-clock)
|
||||
- [Set a per-test timeout with the Bun test runner](https://bun.com/guides/test/timeout)
|
||||
- [Migrate from Jest to Bun's test runner](https://bun.com/guides/test/migrate-from-jest)
|
||||
- [Write browser DOM tests with Bun and happy-dom](https://bun.com/guides/test/happy-dom)
|
||||
- [Mark a test as a "todo" with the Bun test runner](https://bun.com/guides/test/todo-tests)
|
||||
- [Re-run tests multiple times with the Bun test runner](https://bun.com/guides/test/rerun-each)
|
||||
- [Generate code coverage reports with the Bun test runner](https://bun.com/guides/test/coverage)
|
||||
- [import, require, and test Svelte components with bun test](https://bun.com/guides/test/svelte-test)
|
||||
- [Set a code coverage threshold with the Bun test runner](https://bun.com/guides/test/coverage-threshold)
|
||||
|
||||
- Util
|
||||
|
||||
- [Generate a UUID](https://bun.sh/guides/util/javascript-uuid)
|
||||
- [Hash a password](https://bun.sh/guides/util/hash-a-password)
|
||||
- [Escape an HTML string](https://bun.sh/guides/util/escape-html)
|
||||
- [Get the current Bun version](https://bun.sh/guides/util/version)
|
||||
- [Encode and decode base64 strings](https://bun.sh/guides/util/base64)
|
||||
- [Compress and decompress data with gzip](https://bun.sh/guides/util/gzip)
|
||||
- [Sleep for a fixed number of milliseconds](https://bun.sh/guides/util/sleep)
|
||||
- [Detect when code is executed with Bun](https://bun.sh/guides/util/detect-bun)
|
||||
- [Check if two objects are deeply equal](https://bun.sh/guides/util/deep-equals)
|
||||
- [Compress and decompress data with DEFLATE](https://bun.sh/guides/util/deflate)
|
||||
- [Get the absolute path to the current entrypoint](https://bun.sh/guides/util/main)
|
||||
- [Get the directory of the current file](https://bun.sh/guides/util/import-meta-dir)
|
||||
- [Check if the current file is the entrypoint](https://bun.sh/guides/util/entrypoint)
|
||||
- [Get the file name of the current file](https://bun.sh/guides/util/import-meta-file)
|
||||
- [Convert a file URL to an absolute path](https://bun.sh/guides/util/file-url-to-path)
|
||||
- [Convert an absolute path to a file URL](https://bun.sh/guides/util/path-to-file-url)
|
||||
- [Get the absolute path of the current file](https://bun.sh/guides/util/import-meta-path)
|
||||
- [Get the path to an executable bin file](https://bun.sh/guides/util/which-path-to-executable-bin)
|
||||
- [Generate a UUID](https://bun.com/guides/util/javascript-uuid)
|
||||
- [Hash a password](https://bun.com/guides/util/hash-a-password)
|
||||
- [Escape an HTML string](https://bun.com/guides/util/escape-html)
|
||||
- [Get the current Bun version](https://bun.com/guides/util/version)
|
||||
- [Encode and decode base64 strings](https://bun.com/guides/util/base64)
|
||||
- [Compress and decompress data with gzip](https://bun.com/guides/util/gzip)
|
||||
- [Sleep for a fixed number of milliseconds](https://bun.com/guides/util/sleep)
|
||||
- [Detect when code is executed with Bun](https://bun.com/guides/util/detect-bun)
|
||||
- [Check if two objects are deeply equal](https://bun.com/guides/util/deep-equals)
|
||||
- [Compress and decompress data with DEFLATE](https://bun.com/guides/util/deflate)
|
||||
- [Get the absolute path to the current entrypoint](https://bun.com/guides/util/main)
|
||||
- [Get the directory of the current file](https://bun.com/guides/util/import-meta-dir)
|
||||
- [Check if the current file is the entrypoint](https://bun.com/guides/util/entrypoint)
|
||||
- [Get the file name of the current file](https://bun.com/guides/util/import-meta-file)
|
||||
- [Convert a file URL to an absolute path](https://bun.com/guides/util/file-url-to-path)
|
||||
- [Convert an absolute path to a file URL](https://bun.com/guides/util/path-to-file-url)
|
||||
- [Get the absolute path of the current file](https://bun.com/guides/util/import-meta-path)
|
||||
- [Get the path to an executable bin file](https://bun.com/guides/util/which-path-to-executable-bin)
|
||||
|
||||
- WebSocket
|
||||
|
||||
- [Build a publish-subscribe WebSocket server](https://bun.sh/guides/websocket/pubsub)
|
||||
- [Build a simple WebSocket server](https://bun.sh/guides/websocket/simple)
|
||||
- [Enable compression for WebSocket messages](https://bun.sh/guides/websocket/compression)
|
||||
- [Set per-socket contextual data on a WebSocket](https://bun.sh/guides/websocket/context)
|
||||
- [Build a publish-subscribe WebSocket server](https://bun.com/guides/websocket/pubsub)
|
||||
- [Build a simple WebSocket server](https://bun.com/guides/websocket/simple)
|
||||
- [Enable compression for WebSocket messages](https://bun.com/guides/websocket/compression)
|
||||
- [Set per-socket contextual data on a WebSocket](https://bun.com/guides/websocket/context)
|
||||
|
||||
- Write file
|
||||
|
||||
- [Delete a file](https://bun.sh/guides/write-file/unlink)
|
||||
- [Write to stdout](https://bun.sh/guides/write-file/stdout)
|
||||
- [Write a file to stdout](https://bun.sh/guides/write-file/cat)
|
||||
- [Write a Blob to a file](https://bun.sh/guides/write-file/blob)
|
||||
- [Write a string to a file](https://bun.sh/guides/write-file/basic)
|
||||
- [Append content to a file](https://bun.sh/guides/write-file/append)
|
||||
- [Write a file incrementally](https://bun.sh/guides/write-file/filesink)
|
||||
- [Write a Response to a file](https://bun.sh/guides/write-file/response)
|
||||
- [Copy a file to another location](https://bun.sh/guides/write-file/file-cp)
|
||||
- [Write a ReadableStream to a file](https://bun.sh/guides/write-file/stream)
|
||||
- [Delete a file](https://bun.com/guides/write-file/unlink)
|
||||
- [Write to stdout](https://bun.com/guides/write-file/stdout)
|
||||
- [Write a file to stdout](https://bun.com/guides/write-file/cat)
|
||||
- [Write a Blob to a file](https://bun.com/guides/write-file/blob)
|
||||
- [Write a string to a file](https://bun.com/guides/write-file/basic)
|
||||
- [Append content to a file](https://bun.com/guides/write-file/append)
|
||||
- [Write a file incrementally](https://bun.com/guides/write-file/filesink)
|
||||
- [Write a Response to a file](https://bun.com/guides/write-file/response)
|
||||
- [Copy a file to another location](https://bun.com/guides/write-file/file-cp)
|
||||
- [Write a ReadableStream to a file](https://bun.com/guides/write-file/stream)
|
||||
|
||||
## Contributing
|
||||
|
||||
Refer to the [Project > Contributing](https://bun.sh/docs/project/contributing) guide to start contributing to Bun.
|
||||
Refer to the [Project > Contributing](https://bun.com/docs/project/contributing) guide to start contributing to Bun.
|
||||
|
||||
## License
|
||||
|
||||
Refer to the [Project > License](https://bun.sh/docs/project/licensing) page for information about Bun's licensing.
|
||||
Refer to the [Project > License](https://bun.com/docs/project/licensing) page for information about Bun's licensing.
|
||||
|
||||
@@ -8,5 +8,4 @@
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Report any discovered vulnerabilities to the Bun team by emailing `security@bun.sh`. Your report will acknowledged within 5 days, and a team member will be assigned as the primary handler. To the greatest extent possible, the security team will endeavor to keep you informed of the progress being made towards a fix and full announcement, and may ask for additional information or guidance surrounding the reported issue.
|
||||
|
||||
Report any discovered vulnerabilities to the Bun team by emailing `security@bun.com`. Your report will acknowledged within 5 days, and a team member will be assigned as the primary handler. To the greatest extent possible, the security team will endeavor to keep you informed of the progress being made towards a fix and full announcement, and may ask for additional information or guidance surrounding the reported issue.
|
||||
|
||||
@@ -40,4 +40,4 @@ vitest (node v18.11.0)
|
||||
|
||||
> expect().toEqual() x 10000: 401.08ms
|
||||
|
||||
This project was created using `bun init` in bun v0.3.0. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
||||
This project was created using `bun init` in bun v0.3.0. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// To clear your DNS cache on Windows:
|
||||
// ipconfig /flushdns
|
||||
//
|
||||
const url = new URL(process.argv.length > 2 ? process.argv.at(-1) : "https://bun.sh");
|
||||
const url = new URL(process.argv.length > 2 ? process.argv.at(-1) : "https://bun.com");
|
||||
const hostname = url.hostname;
|
||||
const port = url.port ? parseInt(url.port, 10) : url.protocol === "https:" ? 443 : 80;
|
||||
|
||||
|
||||
@@ -34,4 +34,4 @@ For example, when the client sends `"foo"`, the server sends back `"John: foo"`
|
||||
|
||||
The client script waits until it receives all the messages for each client before sending the next batch of messages.
|
||||
|
||||
This project was created using `bun init` in bun v0.2.1. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
||||
This project was created using `bun init` in bun v0.2.1. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
|
||||
|
||||
@@ -522,7 +522,7 @@ for await (const chunk of stream) {
|
||||
}
|
||||
```
|
||||
|
||||
For a more complete discussion of streams in Bun, see [API > Streams](https://bun.sh/docs/api/streams).
|
||||
For a more complete discussion of streams in Bun, see [API > Streams](https://bun.com/docs/api/streams).
|
||||
|
||||
## Conversion
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## Usage (cc in `bun:ffi`)
|
||||
|
||||
See the [introduction blog post](https://bun.sh/blog/compile-and-run-c-in-js) for more information.
|
||||
See the [introduction blog post](https://bun.com/blog/compile-and-run-c-in-js) for more information.
|
||||
|
||||
JavaScript:
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ Bun implements the `node:dns` module.
|
||||
```ts
|
||||
import * as dns from "node:dns";
|
||||
|
||||
const addrs = await dns.promises.resolve4("bun.sh", { ttl: true });
|
||||
const addrs = await dns.promises.resolve4("bun.com", { ttl: true });
|
||||
console.log(addrs);
|
||||
// => [{ address: "172.67.161.226", family: 4, ttl: 0 }, ...]
|
||||
```
|
||||
@@ -54,10 +54,10 @@ Here's an example:
|
||||
```ts
|
||||
import { dns } from "bun";
|
||||
|
||||
dns.prefetch("bun.sh", 443);
|
||||
dns.prefetch("bun.com", 443);
|
||||
//
|
||||
// ... sometime later ...
|
||||
await fetch("https://bun.sh");
|
||||
await fetch("https://bun.com");
|
||||
```
|
||||
|
||||
### `dns.getCacheStats()`
|
||||
|
||||
@@ -267,7 +267,7 @@ const response = await fetch("s3://my-bucket/path/to/object", {
|
||||
|
||||
Note: Only PUT and POST methods support request bodies when using S3. For uploads, Bun automatically uses multipart upload for streaming bodies.
|
||||
|
||||
You can read more about Bun's S3 support in the [S3](https://bun.sh/docs/api/s3) documentation.
|
||||
You can read more about Bun's S3 support in the [S3](https://bun.com/docs/api/s3) documentation.
|
||||
|
||||
#### File URLs - `file://`
|
||||
|
||||
@@ -376,14 +376,14 @@ To prefetch a DNS entry, you can use the `dns.prefetch` API. This API is useful
|
||||
```ts
|
||||
import { dns } from "bun";
|
||||
|
||||
dns.prefetch("bun.sh");
|
||||
dns.prefetch("bun.com");
|
||||
```
|
||||
|
||||
#### DNS caching
|
||||
|
||||
By default, Bun caches and deduplicates DNS queries in-memory for up to 30 seconds. You can see the cache stats by calling `dns.getCacheStats()`:
|
||||
|
||||
To learn more about DNS caching in Bun, see the [DNS caching](https://bun.sh/docs/api/dns) documentation.
|
||||
To learn more about DNS caching in Bun, see the [DNS caching](https://bun.com/docs/api/dns) documentation.
|
||||
|
||||
### Preconnect to a host
|
||||
|
||||
@@ -392,7 +392,7 @@ To preconnect to a host, you can use the `fetch.preconnect` API. This API is use
|
||||
```ts
|
||||
import { fetch } from "bun";
|
||||
|
||||
fetch.preconnect("https://bun.sh");
|
||||
fetch.preconnect("https://bun.com");
|
||||
```
|
||||
|
||||
Note: calling `fetch` immediately after `fetch.preconnect` will not make your request faster. Preconnecting only helps if you know you'll need to connect to a host soon, but you're not ready to make the request yet.
|
||||
@@ -402,7 +402,7 @@ Note: calling `fetch` immediately after `fetch.preconnect` will not make your re
|
||||
To preconnect to a host at startup, you can pass `--fetch-preconnect`:
|
||||
|
||||
```sh
|
||||
$ bun --fetch-preconnect https://bun.sh ./my-script.ts
|
||||
$ bun --fetch-preconnect https://bun.com ./my-script.ts
|
||||
```
|
||||
|
||||
This is sort of like `<link rel="preconnect">` in HTML.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{% callout %}
|
||||
|
||||
<!-- **Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. Existing Node.js projects may use Bun's [nearly complete](https://bun.sh/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module. -->
|
||||
<!-- **Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. Existing Node.js projects may use Bun's [nearly complete](https://bun.com/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module. -->
|
||||
|
||||
**Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. For operations that are not yet available with `Bun.file`, such as `mkdir` or `readdir`, you can use Bun's [nearly complete](https://bun.sh/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module.
|
||||
**Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. For operations that are not yet available with `Bun.file`, such as `mkdir` or `readdir`, you can use Bun's [nearly complete](https://bun.com/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module.
|
||||
|
||||
{% /callout %}
|
||||
|
||||
@@ -208,7 +208,7 @@ await Bun.write(Bun.stdout, input);
|
||||
To write the body of an HTTP response to disk:
|
||||
|
||||
```ts
|
||||
const response = await fetch("https://bun.sh");
|
||||
const response = await fetch("https://bun.com");
|
||||
await Bun.write("index.html", response);
|
||||
```
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ Bun implements the following globals.
|
||||
|
||||
- [`Buffer`](https://nodejs.org/api/buffer.html#class-buffer)
|
||||
- Node.js
|
||||
- See [Node.js > `Buffer`](https://bun.sh/docs/runtime/nodejs-apis#node-buffer)
|
||||
- See [Node.js > `Buffer`](https://bun.com/docs/runtime/nodejs-apis#node-buffer)
|
||||
|
||||
---
|
||||
|
||||
@@ -172,7 +172,7 @@ Bun implements the following globals.
|
||||
|
||||
- [`global`](https://nodejs.org/api/globals.html#global)
|
||||
- Node.js
|
||||
- See [Node.js > `global`](https://bun.sh/docs/runtime/nodejs-apis#global).
|
||||
- See [Node.js > `global`](https://bun.com/docs/runtime/nodejs-apis#global).
|
||||
|
||||
---
|
||||
|
||||
@@ -188,7 +188,7 @@ Bun implements the following globals.
|
||||
|
||||
---
|
||||
|
||||
- [`HTMLRewriter`](https://bun.sh/docs/api/html-rewriter)
|
||||
- [`HTMLRewriter`](https://bun.com/docs/api/html-rewriter)
|
||||
- Cloudflare
|
||||
-
|
||||
|
||||
@@ -220,7 +220,7 @@ Bun implements the following globals.
|
||||
|
||||
- [`process`](https://nodejs.org/api/process.html)
|
||||
- Node.js
|
||||
- See [Node.js > `process`](https://bun.sh/docs/runtime/nodejs-apis#node-process)
|
||||
- See [Node.js > `process`](https://bun.com/docs/runtime/nodejs-apis#node-process)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
The page primarily documents the Bun-native `Bun.serve` API. Bun also implements [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) and the Node.js [`http`](https://nodejs.org/api/http.html) and [`https`](https://nodejs.org/api/https.html) modules.
|
||||
|
||||
{% callout %}
|
||||
These modules have been re-implemented to use Bun's fast internal HTTP infrastructure. Feel free to use these modules directly; frameworks like [Express](https://expressjs.com/) that depend on these modules should work out of the box. For granular compatibility information, see [Runtime > Node.js APIs](https://bun.sh/docs/runtime/nodejs-apis).
|
||||
These modules have been re-implemented to use Bun's fast internal HTTP infrastructure. Feel free to use these modules directly; frameworks like [Express](https://expressjs.com/) that depend on these modules should work out of the box. For granular compatibility information, see [Runtime > Node.js APIs](https://bun.com/docs/runtime/nodejs-apis).
|
||||
{% /callout %}
|
||||
|
||||
To start a high-performance HTTP server with a clean API, the recommended approach is [`Bun.serve`](#start-a-server-bun-serve).
|
||||
@@ -149,7 +149,7 @@ Bun.serve({
|
||||
}),
|
||||
|
||||
// Redirects
|
||||
"/blog": Response.redirect("https://bun.sh/blog"),
|
||||
"/blog": Response.redirect("https://bun.com/blog"),
|
||||
|
||||
// API responses
|
||||
"/api/config": Response.json({
|
||||
@@ -342,9 +342,9 @@ Bun.serve({
|
||||
});
|
||||
```
|
||||
|
||||
HTML imports don't just serve HTML — it's a full-featured frontend bundler, transpiler, and toolkit built using Bun's [bundler](https://bun.sh/docs/bundler), JavaScript transpiler and CSS parser. You can use this to build full-featured frontends with React, TypeScript, Tailwind CSS, and more.
|
||||
HTML imports don't just serve HTML — it's a full-featured frontend bundler, transpiler, and toolkit built using Bun's [bundler](https://bun.com/docs/bundler), JavaScript transpiler and CSS parser. You can use this to build full-featured frontends with React, TypeScript, Tailwind CSS, and more.
|
||||
|
||||
For a complete guide on building full-stack applications with HTML imports, including detailed examples and best practices, see [/docs/bundler/fullstack](https://bun.sh/docs/bundler/fullstack).
|
||||
For a complete guide on building full-stack applications with HTML imports, including detailed examples and best practices, see [/docs/bundler/fullstack](https://bun.com/docs/bundler/fullstack).
|
||||
|
||||
### Practical example: REST API
|
||||
|
||||
@@ -605,7 +605,7 @@ Bun.serve({
|
||||
```
|
||||
|
||||
{% callout %}
|
||||
[Learn more about debugging in Bun](https://bun.sh/docs/runtime/debugger)
|
||||
[Learn more about debugging in Bun](https://bun.com/docs/runtime/debugger)
|
||||
{% /callout %}
|
||||
|
||||
The call to `Bun.serve` returns a `Server` object. To stop the server, call the `.stop()` method.
|
||||
@@ -772,7 +772,7 @@ Instead of passing the server options into `Bun.serve`, `export default` it. Thi
|
||||
$ bun --hot server.ts
|
||||
``` -->
|
||||
|
||||
<!-- It's possible to configure hot reloading while using the explicit `Bun.serve` API; for details refer to [Runtime > Hot reloading](https://bun.sh/docs/runtime/hot). -->
|
||||
<!-- It's possible to configure hot reloading while using the explicit `Bun.serve` API; for details refer to [Runtime > Hot reloading](https://bun.com/docs/runtime/hot). -->
|
||||
|
||||
## Streaming files
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ Production servers often read, upload, and write files to S3-compatible object s
|
||||
|
||||
### Bun's S3 API is fast
|
||||
|
||||
{% image src="https://bun.sh/bun-s3-node.gif" alt="Bun's S3 API is fast" caption="Left: Bun v1.1.44. Right: Node.js v23.6.0" /%}
|
||||
{% image src="https://bun.com/bun-s3-node.gif" alt="Bun's S3 API is fast" caption="Left: Bun v1.1.44. Right: Node.js v23.6.0" /%}
|
||||
|
||||
{% /callout %}
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ const currentFile = import.meta.url;
|
||||
Bun.openInEditor(currentFile);
|
||||
```
|
||||
|
||||
You can override this via the `debug.editor` setting in your [`bunfig.toml`](https://bun.sh/docs/runtime/bunfig).
|
||||
You can override this via the `debug.editor` setting in your [`bunfig.toml`](https://bun.com/docs/runtime/bunfig).
|
||||
|
||||
```toml-diff#bunfig.toml
|
||||
+ [debug]
|
||||
@@ -704,7 +704,7 @@ Bun.nanoseconds();
|
||||
Bun implements a set of convenience functions for asynchronously consuming the body of a `ReadableStream` and converting it to various binary formats.
|
||||
|
||||
```ts
|
||||
const stream = (await fetch("https://bun.sh")).body;
|
||||
const stream = (await fetch("https://bun.com")).body;
|
||||
stream; // => ReadableStream
|
||||
|
||||
await Bun.readableStreamToArrayBuffer(stream);
|
||||
@@ -787,7 +787,7 @@ const buffer = Buffer.alloc(1024 * 1024);
|
||||
estimateShallowMemoryUsageOf(buffer);
|
||||
// => 1048624
|
||||
|
||||
const req = new Request("https://bun.sh");
|
||||
const req = new Request("https://bun.com");
|
||||
estimateShallowMemoryUsageOf(req);
|
||||
// => 167
|
||||
|
||||
|
||||
@@ -325,7 +325,7 @@ When adding a build step is too complicated, you can set `development: false` in
|
||||
|
||||
## Plugins
|
||||
|
||||
Bun's [bundler plugins](https://bun.sh/docs/bundler/plugins) are also supported when bundling static routes.
|
||||
Bun's [bundler plugins](https://bun.com/docs/bundler/plugins) are also supported when bundling static routes.
|
||||
|
||||
To configure plugins for `Bun.serve`, add a `plugins` array in the `[serve.static]` section of your `bunfig.toml`.
|
||||
|
||||
@@ -365,7 +365,7 @@ Or in your CSS:
|
||||
|
||||
### Custom plugins
|
||||
|
||||
Any JS file or module which exports a [valid bundler plugin object](https://bun.sh/docs/bundler/plugins#usage) (essentially an object with a `name` and `setup` field) can be placed inside the `plugins` array:
|
||||
Any JS file or module which exports a [valid bundler plugin object](https://bun.com/docs/bundler/plugins#usage) (essentially an object with a `name` and `setup` field) can be placed inside the `plugins` array:
|
||||
|
||||
```toml#bunfig.toml
|
||||
[serve.static]
|
||||
|
||||
@@ -147,7 +147,7 @@ $ bun build ./index.tsx --outdir ./out --watch
|
||||
|
||||
## Content types
|
||||
|
||||
Like the Bun runtime, the bundler supports an array of file types out of the box. The following table breaks down the bundler's set of standard "loaders". Refer to [Bundler > File types](https://bun.sh/docs/runtime/loaders) for full documentation.
|
||||
Like the Bun runtime, the bundler supports an array of file types out of the box. The following table breaks down the bundler's set of standard "loaders". Refer to [Bundler > File types](https://bun.com/docs/runtime/loaders) for full documentation.
|
||||
|
||||
{% table %}
|
||||
|
||||
@@ -220,11 +220,11 @@ console.log(logo);
|
||||
The exact behavior of the file loader is also impacted by [`naming`](#naming) and [`publicPath`](#publicpath).
|
||||
{% /callout %}
|
||||
|
||||
Refer to the [Bundler > Loaders](https://bun.sh/docs/bundler/loaders#file) page for more complete documentation on the file loader.
|
||||
Refer to the [Bundler > Loaders](https://bun.com/docs/bundler/loaders#file) page for more complete documentation on the file loader.
|
||||
|
||||
### Plugins
|
||||
|
||||
The behavior described in this table can be overridden or extended with [plugins](https://bun.sh/docs/bundler/plugins). Refer to the [Bundler > Loaders](https://bun.sh/docs/bundler/plugins) page for complete documentation.
|
||||
The behavior described in this table can be overridden or extended with [plugins](https://bun.com/docs/bundler/plugins). Refer to the [Bundler > Loaders](https://bun.com/docs/bundler/plugins) page for complete documentation.
|
||||
|
||||
## API
|
||||
|
||||
@@ -484,7 +484,7 @@ n/a
|
||||
|
||||
{% /codetabs %}
|
||||
|
||||
Bun implements a universal plugin system for both Bun's runtime and bundler. Refer to the [plugin documentation](https://bun.sh/docs/bundler/plugins) for complete documentation.
|
||||
Bun implements a universal plugin system for both Bun's runtime and bundler. Refer to the [plugin documentation](https://bun.com/docs/bundler/plugins) for complete documentation.
|
||||
|
||||
<!-- ### `manifest`
|
||||
|
||||
@@ -1102,7 +1102,7 @@ A prefix to be appended to any import paths in bundled code.
|
||||
|
||||
In many cases, generated bundles will contain no `import` statements. After all, the goal of bundling is to combine all of the code into a single file. However there are a number of cases with the generated bundles will contain `import` statements.
|
||||
|
||||
- **Asset imports** — When importing an unrecognized file type like `*.svg`, the bundler defers to the [`file` loader](https://bun.sh/docs/bundler/loaders#file), which copies the file into `outdir` as is. The import is converted into a variable
|
||||
- **Asset imports** — When importing an unrecognized file type like `*.svg`, the bundler defers to the [`file` loader](https://bun.com/docs/bundler/loaders#file), which copies the file into `outdir` as is. The import is converted into a variable
|
||||
- **External modules** — Files and modules can be marked as [`external`](#external), in which case they will not be included in the bundle. Instead, the `import` statement will be left in the final bundle.
|
||||
- **Chunking**. When [`splitting`](#splitting) is enabled, the bundler may generate separate "chunk" files that represent code that is shared among multiple entrypoints.
|
||||
|
||||
@@ -1178,7 +1178,7 @@ $ bun build ./index.tsx --outdir ./out --define 'STRING="value"' --define "neste
|
||||
|
||||
### `loader`
|
||||
|
||||
A map of file extensions to [built-in loader names](https://bun.sh/docs/bundler/loaders#built-in-loaders). This can be used to quickly customize how certain files are loaded.
|
||||
A map of file extensions to [built-in loader names](https://bun.com/docs/bundler/loaders#built-in-loaders). This can be used to quickly customize how certain files are loaded.
|
||||
|
||||
{% codetabs %}
|
||||
|
||||
@@ -1310,7 +1310,7 @@ Each artifact also contains the following properties:
|
||||
---
|
||||
|
||||
- `loader`
|
||||
- The loader was used to interpret the file. See [Bundler > Loaders](https://bun.sh/docs/bundler/loaders) to see how Bun maps file extensions to the appropriate built-in loader.
|
||||
- The loader was used to interpret the file. See [Bundler > Loaders](https://bun.com/docs/bundler/loaders) to see how Bun maps file extensions to the appropriate built-in loader.
|
||||
|
||||
---
|
||||
|
||||
@@ -1394,7 +1394,7 @@ $ bun build ./cli.tsx --outfile mycli --compile
|
||||
$ ./mycli
|
||||
```
|
||||
|
||||
Refer to [Bundler > Executables](https://bun.sh/docs/bundler/executables) for complete documentation.
|
||||
Refer to [Bundler > Executables](https://bun.com/docs/bundler/executables) for complete documentation.
|
||||
|
||||
## Logs and errors
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ The Bun bundler implements a set of default loaders out of the box. As a rule of
|
||||
|
||||
`.js` `.cjs` `.mjs` `.mts` `.cts` `.ts` `.tsx` `.jsx` `.toml` `.json` `.txt` `.wasm` `.node` `.html`
|
||||
|
||||
Bun uses the file extension to determine which built-in _loader_ should be used to parse the file. Every loader has a name, such as `js`, `tsx`, or `json`. These names are used when building [plugins](https://bun.sh/docs/bundler/plugins) that extend Bun with custom loaders.
|
||||
Bun uses the file extension to determine which built-in _loader_ should be used to parse the file. Every loader has a name, such as `js`, `tsx`, or `json`. These names are used when building [plugins](https://bun.com/docs/bundler/plugins) that extend Bun with custom loaders.
|
||||
|
||||
You can explicitly specify which loader to use using the 'loader' import attribute.
|
||||
|
||||
@@ -175,7 +175,7 @@ In the bundler, `.node` files are handled using the [`file`](#file) loader.
|
||||
|
||||
**SQLite loader**. `with { "type": "sqlite" }` import attribute
|
||||
|
||||
In the runtime and bundler, SQLite databases can be directly imported. This will load the database using [`bun:sqlite`](https://bun.sh/docs/api/sqlite).
|
||||
In the runtime and bundler, SQLite databases can be directly imported. This will load the database using [`bun:sqlite`](https://bun.com/docs/api/sqlite).
|
||||
|
||||
```ts
|
||||
import db from "./my.db" with { type: "sqlite" };
|
||||
@@ -192,7 +192,7 @@ You can change this behavior with the `"embed"` attribute:
|
||||
import db from "./my.db" with { type: "sqlite", embed: "true" };
|
||||
```
|
||||
|
||||
When using a [standalone executable](https://bun.sh/docs/bundler/executables), the database is embedded into the single-file executable.
|
||||
When using a [standalone executable](https://bun.com/docs/bundler/executables), the database is embedded into the single-file executable.
|
||||
|
||||
Otherwise, the database to embed is copied into the `outdir` with a hashed filename.
|
||||
|
||||
@@ -280,7 +280,7 @@ The `html` loader behaves differently depending on how it's used:
|
||||
|
||||
**Bun Shell loader**. Default for `.sh` files
|
||||
|
||||
This loader is used to parse [Bun Shell](https://bun.sh/docs/runtime/shell) scripts. It's only supported when starting Bun itself, so it's not available in the bundler or in the runtime.
|
||||
This loader is used to parse [Bun Shell](https://bun.com/docs/runtime/shell) scripts. It's only supported when starting Bun itself, so it's not available in the bundler or in the runtime.
|
||||
|
||||
```sh
|
||||
$ bun run ./script.sh
|
||||
@@ -336,7 +336,7 @@ If a value is specified for `publicPath`, the import will use value as a prefix
|
||||
{% /table %}
|
||||
|
||||
{% callout %}
|
||||
The location and file name of the copied file is determined by the value of [`naming.asset`](https://bun.sh/docs/bundler#naming).
|
||||
The location and file name of the copied file is determined by the value of [`naming.asset`](https://bun.com/docs/bundler#naming).
|
||||
{% /callout %}
|
||||
This loader is copied into the `outdir` as-is. The name of the copied file is determined using the value of `naming.asset`.
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ The result of `fetch` is `Promise<Response>`, so it can be directly returned.
|
||||
|
||||
```ts#macro.ts
|
||||
export function getObject() {
|
||||
return fetch("https://bun.sh")
|
||||
return fetch("https://bun.com")
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ One of the reasons why Bun's bundler is so fast is that it is written in native
|
||||
|
||||
However, one limitation of plugins written in JavaScript is that JavaScript itself is single-threaded.
|
||||
|
||||
Native plugins are written as [NAPI](https://bun.sh/docs/api/node-api) modules and can be run on multiple threads. This allows native plugins to run much faster than JavaScript plugins.
|
||||
Native plugins are written as [NAPI](https://bun.com/docs/api/node-api) modules and can be run on multiple threads. This allows native plugins to run much faster than JavaScript plugins.
|
||||
|
||||
In addition, native plugins can skip unnecessary work such as the UTF-8 -> UTF-16 conversion needed to pass strings to JavaScript.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ Bun's bundler API is inspired heavily by [esbuild](https://esbuild.github.io/).
|
||||
|
||||
There are a few behavioral differences to note.
|
||||
|
||||
- **Bundling by default**. Unlike esbuild, Bun _always bundles by default_. This is why the `--bundle` flag isn't necessary in the Bun example. To transpile each file individually, use [`Bun.Transpiler`](https://bun.sh/docs/api/transpiler).
|
||||
- **Bundling by default**. Unlike esbuild, Bun _always bundles by default_. This is why the `--bundle` flag isn't necessary in the Bun example. To transpile each file individually, use [`Bun.Transpiler`](https://bun.com/docs/api/transpiler).
|
||||
- **It's just a bundler**. Unlike esbuild, Bun's bundler does not include a built-in development server or file watcher. It's just a bundler. The bundler is intended for use in conjunction with `Bun.serve` and other runtime APIs to achieve the same effect. As such, all options relating to HTTP/file watching are not applicable.
|
||||
|
||||
## Performance
|
||||
@@ -65,7 +65,7 @@ In Bun's CLI, simple boolean flags like `--minify` do not accept an argument. Ot
|
||||
|
||||
- `--loader:.ext=loader`
|
||||
- `--loader .ext:loader`
|
||||
- Bun supports a different set of built-in loaders than esbuild; see [Bundler > Loaders](https://bun.sh/docs/bundler/loaders) for a complete reference. The esbuild loaders `dataurl`, `binary`, `base64`, `copy`, and `empty` are not yet implemented.
|
||||
- Bun supports a different set of built-in loaders than esbuild; see [Bundler > Loaders](https://bun.com/docs/bundler/loaders) for a complete reference. The esbuild loaders `dataurl`, `binary`, `base64`, `copy`, and `empty` are not yet implemented.
|
||||
|
||||
The syntax for `--loader` is slightly different.
|
||||
|
||||
@@ -474,7 +474,7 @@ In Bun's CLI, simple boolean flags like `--minify` do not accept an argument. Ot
|
||||
|
||||
- `bundle`
|
||||
- n/a
|
||||
- Always `true`. Use [`Bun.Transpiler`](https://bun.sh/docs/api/transpiler) to transpile without bundling.
|
||||
- Always `true`. Use [`Bun.Transpiler`](https://bun.com/docs/api/transpiler) to transpile without bundling.
|
||||
|
||||
---
|
||||
|
||||
@@ -635,7 +635,7 @@ In Bun's CLI, simple boolean flags like `--minify` do not accept an argument. Ot
|
||||
|
||||
- `loader`
|
||||
- `loader`
|
||||
- Bun supports a different set of built-in loaders than esbuild; see [Bundler > Loaders](https://bun.sh/docs/bundler/loaders) for a complete reference. The esbuild loaders `dataurl`, `binary`, `base64`, `copy`, and `empty` are not yet implemented.
|
||||
- Bun supports a different set of built-in loaders than esbuild; see [Bundler > Loaders](https://bun.com/docs/bundler/loaders) for a complete reference. The esbuild loaders `dataurl`, `binary`, `base64`, `copy`, and `empty` are not yet implemented.
|
||||
|
||||
---
|
||||
|
||||
@@ -891,7 +891,7 @@ const myPlugin: BunPlugin = {
|
||||
};
|
||||
```
|
||||
|
||||
The `builder` object provides some methods for hooking into parts of the bundling process. Bun implements `onResolve` and `onLoad`; it does not yet implement the esbuild hooks `onStart`, `onEnd`, and `onDispose`, and `resolve` utilities. `initialOptions` is partially implemented, being read-only and only having a subset of esbuild's options; use [`config`](https://bun.sh/docs/bundler/plugins) (same thing but with Bun's `BuildConfig` format) instead.
|
||||
The `builder` object provides some methods for hooking into parts of the bundling process. Bun implements `onResolve` and `onLoad`; it does not yet implement the esbuild hooks `onStart`, `onEnd`, and `onDispose`, and `resolve` utilities. `initialOptions` is partially implemented, being read-only and only having a subset of esbuild's options; use [`config`](https://bun.com/docs/bundler/plugins) (same thing but with Bun's `BuildConfig` format) instead.
|
||||
|
||||
```ts
|
||||
import type { BunPlugin } from "bun";
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
Template a new Bun project with `bun create`. This is a flexible command that can be used to create a new project from a React component, a `create-<template>` npm package, a GitHub repo, or a local template.
|
||||
|
||||
If you're looking to create a brand new empty project, use [`bun init`](https://bun.sh/docs/cli/init).
|
||||
If you're looking to create a brand new empty project, use [`bun init`](https://bun.com/docs/cli/init).
|
||||
|
||||
## From a React component
|
||||
|
||||
@@ -30,11 +30,11 @@ $ bun create ./MyComponent.jsx # .tsx also supported
|
||||
|
||||
When you run `bun create <component>`, Bun:
|
||||
|
||||
1. Uses [Bun's JavaScript bundler](https://bun.sh/docs/bundler) to analyze your module graph.
|
||||
1. Uses [Bun's JavaScript bundler](https://bun.com/docs/bundler) to analyze your module graph.
|
||||
2. Collects all the dependencies needed to run the component.
|
||||
3. Scans the exports of the entry point for a React component.
|
||||
4. Generates a `package.json` file with the dependencies and scripts needed to run the component.
|
||||
5. Installs any missing dependencies using [`bun install --only-missing`](https://bun.sh/docs/cli/install).
|
||||
5. Installs any missing dependencies using [`bun install --only-missing`](https://bun.com/docs/cli/install).
|
||||
6. Generates the following files:
|
||||
- `${component}.html`
|
||||
- `${component}.client.tsx` (entry point for the frontend)
|
||||
|
||||
@@ -184,7 +184,7 @@ Peer dependencies are handled similarly to yarn. `bun install` will automaticall
|
||||
|
||||
## Lockfile
|
||||
|
||||
`bun.lock` is Bun’s lockfile format. See [our blogpost about the text lockfile](https://bun.sh/blog/bun-lock-text-lockfile).
|
||||
`bun.lock` is Bun’s lockfile format. See [our blogpost about the text lockfile](https://bun.com/blog/bun-lock-text-lockfile).
|
||||
|
||||
Prior to Bun 1.2, the lockfile was binary and called `bun.lockb`. Old lockfiles can be upgraded to the new format by running `bun install --save-text-lockfile --frozen-lockfile --lockfile-only`, and then deleting `bun.lockb`.
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ This works by checking the latest version of Bun in [bun-releases-for-updater](h
|
||||
If for any reason you run into issues, you can also use the curl install script:
|
||||
|
||||
```bash
|
||||
$ curl https://bun.sh/install | bash
|
||||
$ curl https://bun.com/install | bash
|
||||
```
|
||||
|
||||
It will still work when Bun is already installed.
|
||||
|
||||
@@ -41,7 +41,7 @@ $ bun outdated --filter 'pkg-*'
|
||||
$ bun outdated --filter './'
|
||||
```
|
||||
|
||||
For more information on both these commands, see [`bun install`](https://bun.sh/docs/cli/install) and [`bun outdated`](https://bun.sh/docs/cli/outdated).
|
||||
For more information on both these commands, see [`bun install`](https://bun.com/docs/cli/install) and [`bun outdated`](https://bun.com/docs/cli/outdated).
|
||||
|
||||
## Running scripts with `--filter`
|
||||
|
||||
@@ -73,7 +73,7 @@ Both commands will be run in parallel, and you will see a nice terminal UI showi
|
||||
|
||||
### Running scripts in workspaces
|
||||
|
||||
Filters respect your [workspace configuration](https://bun.sh/docs/install/workspaces): If you have a `package.json` file that specifies which packages are part of the workspace,
|
||||
Filters respect your [workspace configuration](https://bun.com/docs/install/workspaces): If you have a `package.json` file that specifies which packages are part of the workspace,
|
||||
`--filter` will be restricted to only these packages. Also, in a workspace you can use `--filter` to run scripts in packages that are located anywhere in the workspace:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -68,7 +68,7 @@ $ bun install --concurrent-scripts 5
|
||||
|
||||
## Workspaces
|
||||
|
||||
Bun supports `"workspaces"` in package.json. For complete documentation refer to [Package manager > Workspaces](https://bun.sh/docs/install/workspaces).
|
||||
Bun supports `"workspaces"` in package.json. For complete documentation refer to [Package manager > Workspaces](https://bun.com/docs/install/workspaces).
|
||||
|
||||
```json#package.json
|
||||
{
|
||||
@@ -93,11 +93,11 @@ $ bun install --filter '!pkg-c'
|
||||
$ bun install --filter './packages/pkg-a'
|
||||
```
|
||||
|
||||
For more information on filtering with `bun install`, refer to [Package Manager > Filtering](https://bun.sh/docs/cli/filter#bun-install-and-bun-outdated)
|
||||
For more information on filtering with `bun install`, refer to [Package Manager > Filtering](https://bun.com/docs/cli/filter#bun-install-and-bun-outdated)
|
||||
|
||||
## Overrides and resolutions
|
||||
|
||||
Bun supports npm's `"overrides"` and Yarn's `"resolutions"` in `package.json`. These are mechanisms for specifying a version range for _metadependencies_—the dependencies of your dependencies. Refer to [Package manager > Overrides and resolutions](https://bun.sh/docs/install/overrides) for complete documentation.
|
||||
Bun supports npm's `"overrides"` and Yarn's `"resolutions"` in `package.json`. These are mechanisms for specifying a version range for _metadependencies_—the dependencies of your dependencies. Refer to [Package manager > Overrides and resolutions](https://bun.com/docs/install/overrides) for complete documentation.
|
||||
|
||||
```json-diff#package.json
|
||||
{
|
||||
@@ -142,7 +142,7 @@ For reproducible installs, use `--frozen-lockfile`. This will install the exact
|
||||
$ bun install --frozen-lockfile
|
||||
```
|
||||
|
||||
For more information on Bun's lockfile `bun.lock`, refer to [Package manager > Lockfile](https://bun.sh/docs/install/lockfile).
|
||||
For more information on Bun's lockfile `bun.lock`, refer to [Package manager > Lockfile](https://bun.com/docs/install/lockfile).
|
||||
|
||||
## Omitting dependencies
|
||||
|
||||
@@ -168,7 +168,7 @@ $ bun install --dry-run
|
||||
|
||||
## Non-npm dependencies
|
||||
|
||||
Bun supports installing dependencies from Git, GitHub, and local or remotely-hosted tarballs. For complete documentation refer to [Package manager > Git, GitHub, and tarball dependencies](https://bun.sh/docs/cli/add).
|
||||
Bun supports installing dependencies from Git, GitHub, and local or remotely-hosted tarballs. For complete documentation refer to [Package manager > Git, GitHub, and tarball dependencies](https://bun.com/docs/cli/add).
|
||||
|
||||
```json#package.json
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
An alias for `bun patch --commit` to maintain compatibility with pnpm.
|
||||
|
||||
To get started with patch, first prepare the package for patching with [`bun patch <pkg>`](https://bun.sh/docs/install/patch).
|
||||
To get started with patch, first prepare the package for patching with [`bun patch <pkg>`](https://bun.com/docs/install/patch).
|
||||
|
||||
### `--patches-dir`
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ $ bun run clean
|
||||
Done.
|
||||
```
|
||||
|
||||
Bun executes the script command in a subshell. On Linux & macOS, it checks for the following shells in order, using the first one it finds: `bash`, `sh`, `zsh`. On windows, it uses [bun shell](https://bun.sh/docs/runtime/shell) to support bash-like syntax and many common commands.
|
||||
Bun executes the script command in a subshell. On Linux & macOS, it checks for the following shells in order, using the first one it finds: `bash`, `sh`, `zsh`. On windows, it uses [bun shell](https://bun.com/docs/runtime/shell) to support bash-like syntax and many common commands.
|
||||
|
||||
{% callout %}
|
||||
⚡️ The startup time for `npm run` on Linux is roughly 170ms; with Bun it is `6ms`.
|
||||
@@ -164,7 +164,7 @@ bun run --filter 'ba*' <script>
|
||||
|
||||
will execute `<script>` in both `bar` and `baz`, but not in `foo`.
|
||||
|
||||
Find more details in the docs page for [filter](https://bun.sh/docs/cli/filter#running-scripts-with-filter).
|
||||
Find more details in the docs page for [filter](https://bun.com/docs/cli/filter#running-scripts-with-filter).
|
||||
|
||||
## `bun run -` to pipe code from stdin
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ Bun aims for compatibility with Jest, but not everything is implemented. To trac
|
||||
$ bun test
|
||||
```
|
||||
|
||||
Tests are written in JavaScript or TypeScript with a Jest-like API. Refer to [Writing tests](https://bun.sh/docs/test/writing) for full documentation.
|
||||
Tests are written in JavaScript or TypeScript with a Jest-like API. Refer to [Writing tests](https://bun.com/docs/test/writing) for full documentation.
|
||||
|
||||
```ts#math.test.ts
|
||||
import { expect, test } from "bun:test";
|
||||
@@ -53,7 +53,7 @@ To run a specific file in the test runner, make sure the path starts with `./` o
|
||||
$ bun test ./test/specific-file.test.ts
|
||||
```
|
||||
|
||||
The test runner runs all tests in a single process. It loads all `--preload` scripts (see [Lifecycle](https://bun.sh/docs/test/lifecycle) for details), then runs all tests. If a test fails, the test runner will exit with a non-zero exit code.
|
||||
The test runner runs all tests in a single process. It loads all `--preload` scripts (see [Lifecycle](https://bun.com/docs/test/lifecycle) for details), then runs all tests. If a test fails, the test runner will exit with a non-zero exit code.
|
||||
|
||||
## CI/CD integration
|
||||
|
||||
@@ -154,7 +154,7 @@ These hooks can be defined inside test files, or in a separate file that is prel
|
||||
$ bun test --preload ./setup.ts
|
||||
```
|
||||
|
||||
See [Test > Lifecycle](https://bun.sh/docs/test/lifecycle) for complete documentation.
|
||||
See [Test > Lifecycle](https://bun.com/docs/test/lifecycle) for complete documentation.
|
||||
|
||||
## Mocks
|
||||
|
||||
@@ -182,7 +182,7 @@ Alternatively, you can use `jest.fn()`, it behaves identically.
|
||||
+ const random = jest.fn(() => Math.random());
|
||||
```
|
||||
|
||||
See [Test > Mocks](https://bun.sh/docs/test/mocks) for complete documentation.
|
||||
See [Test > Mocks](https://bun.com/docs/test/mocks) for complete documentation.
|
||||
|
||||
## Snapshot testing
|
||||
|
||||
@@ -203,7 +203,7 @@ To update snapshots, use the `--update-snapshots` flag.
|
||||
$ bun test --update-snapshots
|
||||
```
|
||||
|
||||
See [Test > Snapshots](https://bun.sh/docs/test/snapshots) for complete documentation.
|
||||
See [Test > Snapshots](https://bun.com/docs/test/snapshots) for complete documentation.
|
||||
|
||||
## UI & DOM testing
|
||||
|
||||
@@ -213,7 +213,7 @@ Bun is compatible with popular UI testing libraries:
|
||||
- [DOM Testing Library](https://testing-library.com/docs/dom-testing-library/intro/)
|
||||
- [React Testing Library](https://testing-library.com/docs/react-testing-library/intro)
|
||||
|
||||
See [Test > DOM Testing](https://bun.sh/docs/test/dom) for complete documentation.
|
||||
See [Test > DOM Testing](https://bun.com/docs/test/dom) for complete documentation.
|
||||
|
||||
## Performance
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Projects that use Express and other major Node.js HTTP libraries should work out of the box.
|
||||
|
||||
{% callout %}
|
||||
If you run into bugs, [please file an issue](https://bun.sh/issues) _in Bun's repo_, not the library. It is Bun's responsibility to address Node.js compatibility issues.
|
||||
If you run into bugs, [please file an issue](https://bun.com/issues) _in Bun's repo_, not the library. It is Bun's responsibility to address Node.js compatibility issues.
|
||||
{% /callout %}
|
||||
|
||||
```ts
|
||||
@@ -19,10 +19,10 @@ app.listen(port, () => {
|
||||
});
|
||||
```
|
||||
|
||||
Bun implements the [`node:http`](https://nodejs.org/api/http.html) and [`node:https`](https://nodejs.org/api/https.html) modules that these libraries rely on. These modules can also be used directly, though [`Bun.serve`](https://bun.sh/docs/api/http) is recommended for most use cases.
|
||||
Bun implements the [`node:http`](https://nodejs.org/api/http.html) and [`node:https`](https://nodejs.org/api/https.html) modules that these libraries rely on. These modules can also be used directly, though [`Bun.serve`](https://bun.com/docs/api/http) is recommended for most use cases.
|
||||
|
||||
{% callout %}
|
||||
**Note** — Refer to the [Runtime > Node.js APIs](https://bun.sh/docs/runtime/nodejs-apis#node-http) page for more detailed compatibility information.
|
||||
**Note** — Refer to the [Runtime > Node.js APIs](https://bun.com/docs/runtime/nodejs-apis#node-http) page for more detailed compatibility information.
|
||||
{% /callout %}
|
||||
|
||||
```ts
|
||||
|
||||
@@ -36,7 +36,7 @@ function Div(props: {className: string;}) {
|
||||
|
||||
### Server-side rendering
|
||||
|
||||
To server-side render (SSR) React in an [HTTP server](https://bun.sh/docs/api/http):
|
||||
To server-side render (SSR) React in an [HTTP server](https://bun.com/docs/api/http):
|
||||
|
||||
```tsx#ssr.tsx
|
||||
import {renderToReadableStream} from 'react-dom/server';
|
||||
|
||||
@@ -24,4 +24,4 @@ const regularArr = Array.from(uintArr);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -21,4 +21,4 @@ blob.type; // => "application/octet-stream"
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -22,4 +22,4 @@ const nodeBuffer = Buffer.from(arrBuffer, 0, 16); // view first 16 bytes
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -12,4 +12,4 @@ const str = decoder.decode(buf);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -36,4 +36,4 @@ const arr = new Uint8Array(buffer, 0, 16); // view first 16 bytes
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Utils](https://bun.sh/docs/api/utils) for more useful utilities.
|
||||
See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities.
|
||||
|
||||
@@ -11,4 +11,4 @@ const buf = await blob.arrayBuffer();
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -11,4 +11,4 @@ const arr = new DataView(await blob.arrayBuffer());
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -11,4 +11,4 @@ const stream = await blob.stream();
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -12,4 +12,4 @@ const str = await blob.text();
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -11,4 +11,4 @@ const arr = new Uint8Array(await blob.arrayBuffer());
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -11,4 +11,4 @@ const arrBuf = nodeBuf.buffer;
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -11,4 +11,4 @@ const blob = new Blob([buf]);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -38,4 +38,4 @@ const stream = blob.stream(1024);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -22,4 +22,4 @@ const str = buf.toString("utf8", 0, 5);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -11,4 +11,4 @@ buf instanceof Uint8Array; // => true
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -12,4 +12,4 @@ const str = decoder.decode(dv);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -22,4 +22,4 @@ arr.byteLength; // => 32
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -13,4 +13,4 @@ console.log(await blob.text());
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -11,4 +11,4 @@ const buf = Buffer.from(arr);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -11,4 +11,4 @@ const dv = new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -38,4 +38,4 @@ const stream = blob.stream(1024);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -13,4 +13,4 @@ const str = decoder.decode(arr);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.sh/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -5,7 +5,7 @@ name: Build an HTTP server using Express and Bun
|
||||
Express and other major Node.js HTTP libraries should work out of the box. Bun implements the [`node:http`](https://nodejs.org/api/http.html) and [`node:https`](https://nodejs.org/api/https.html) modules that these libraries rely on.
|
||||
|
||||
{% callout %}
|
||||
Refer to the [Runtime > Node.js APIs](https://bun.sh/docs/runtime/nodejs-apis#node-http) page for more detailed compatibility information.
|
||||
Refer to the [Runtime > Node.js APIs](https://bun.com/docs/runtime/nodejs-apis#node-http) page for more detailed compatibility information.
|
||||
{% /callout %}
|
||||
|
||||
```sh
|
||||
|
||||
@@ -31,7 +31,7 @@ import { neon } from '@neondatabase/serverless';
|
||||
import { drizzle } from 'drizzle-orm/neon-http';
|
||||
|
||||
// Bun automatically loads the DATABASE_URL from .env.local
|
||||
// Refer to: https://bun.sh/docs/runtime/env for more information
|
||||
// Refer to: https://bun.com/docs/runtime/env for more information
|
||||
const sql = neon(process.env.DATABASE_URL!);
|
||||
|
||||
export const db = drizzle(sql);
|
||||
|
||||
@@ -31,7 +31,7 @@ Paste the following code into your project's `index.ts` file.
|
||||
import { neon } from "@neondatabase/serverless";
|
||||
|
||||
// Bun automatically loads the DATABASE_URL from .env.local
|
||||
// Refer to: https://bun.sh/docs/runtime/env for more information
|
||||
// Refer to: https://bun.com/docs/runtime/env for more information
|
||||
const sql = neon(process.env.DATABASE_URL);
|
||||
|
||||
const rows = await sql`SELECT version()`;
|
||||
|
||||
@@ -4,7 +4,7 @@ name: Extract links from a webpage using HTMLRewriter
|
||||
|
||||
## Extract links from a webpage
|
||||
|
||||
Bun's [HTMLRewriter](https://bun.sh/docs/api/html-rewriter) API can be used to efficiently extract links from HTML content. It works by chaining together CSS selectors to match the elements, text, and attributes you want to process. This is a simple example of how to extract links from a webpage. You can pass `.transform` a `Response`, `Blob`, or `string`.
|
||||
Bun's [HTMLRewriter](https://bun.com/docs/api/html-rewriter) API can be used to efficiently extract links from HTML content. It works by chaining together CSS selectors to match the elements, text, and attributes you want to process. This is a simple example of how to extract links from a webpage. You can pass `.transform` a `Response`, `Blob`, or `string`.
|
||||
|
||||
```ts
|
||||
async function extractLinks(url: string) {
|
||||
@@ -22,11 +22,11 @@ async function extractLinks(url: string) {
|
||||
|
||||
// Wait for the response to be processed
|
||||
await rewriter.transform(response).blob();
|
||||
console.log([...links]); // ["https://bun.sh", "/docs", ...]
|
||||
console.log([...links]); // ["https://bun.com", "/docs", ...]
|
||||
}
|
||||
|
||||
// Extract all links from the Bun website
|
||||
await extractLinks("https://bun.sh");
|
||||
await extractLinks("https://bun.com");
|
||||
```
|
||||
|
||||
---
|
||||
@@ -65,4 +65,4 @@ const websiteLinks = await extractLinksFromURL("https://example.com");
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > HTMLRewriter](https://bun.sh/docs/api/html-rewriter) for complete documentation on HTML transformation with Bun.
|
||||
See [Docs > API > HTMLRewriter](https://bun.com/docs/api/html-rewriter) for complete documentation on HTML transformation with Bun.
|
||||
|
||||
@@ -4,7 +4,7 @@ name: Extract social share images and Open Graph tags
|
||||
|
||||
## Extract social share images and Open Graph tags
|
||||
|
||||
Bun's [HTMLRewriter](https://bun.sh/docs/api/html-rewriter) API can be used to efficiently extract social share images and Open Graph metadata from HTML content. This is particularly useful for building link preview features, social media cards, or web scrapers. We can use HTMLRewriter to match CSS selectors to HTML elements, text, and attributes we want to process.
|
||||
Bun's [HTMLRewriter](https://bun.com/docs/api/html-rewriter) API can be used to efficiently extract social share images and Open Graph metadata from HTML content. This is particularly useful for building link preview features, social media cards, or web scrapers. We can use HTMLRewriter to match CSS selectors to HTML elements, text, and attributes we want to process.
|
||||
|
||||
```ts
|
||||
interface SocialMetadata {
|
||||
@@ -81,12 +81,12 @@ async function extractSocialMetadata(url: string): Promise<SocialMetadata> {
|
||||
}
|
||||
|
||||
// Example usage
|
||||
const metadata = await extractSocialMetadata("https://bun.sh");
|
||||
const metadata = await extractSocialMetadata("https://bun.com");
|
||||
console.log(metadata);
|
||||
// {
|
||||
// title: "Bun — A fast all-in-one JavaScript runtime",
|
||||
// description: "Bundle, transpile, install and run JavaScript & TypeScript projects — all in Bun. 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.",
|
||||
// image: "https://bun.sh/share.jpg",
|
||||
// image: "https://bun.com/share.jpg",
|
||||
// type: "website",
|
||||
// ...
|
||||
// }
|
||||
|
||||
@@ -5,7 +5,7 @@ name: Send an HTTP request using fetch
|
||||
Bun implements the Web-standard [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) API for sending HTTP requests. To send a simple `GET` request to a URL:
|
||||
|
||||
```ts
|
||||
const response = await fetch("https://bun.sh");
|
||||
const response = await fetch("https://bun.com");
|
||||
const html = await response.text(); // HTML string
|
||||
```
|
||||
|
||||
@@ -14,7 +14,7 @@ const html = await response.text(); // HTML string
|
||||
To send a `POST` request to an API endpoint.
|
||||
|
||||
```ts
|
||||
const response = await fetch("https://bun.sh/api", {
|
||||
const response = await fetch("https://bun.com/api", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ message: "Hello from Bun!" }),
|
||||
headers: { "Content-Type": "application/json" },
|
||||
|
||||
@@ -61,7 +61,7 @@ Our form will send a `POST` request to the `/action` endpoint with the form data
|
||||
|
||||
First we use the [`.formData()`](https://developer.mozilla.org/en-US/docs/Web/API/Request/formData) method on the incoming `Request` to asynchronously parse its contents to a `FormData` instance. Then we can use the [`.get()`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/get) method to extract the value of the `name` and `profilePicture` fields. Here `name` corresponds to a `string` and `profilePicture` is a `Blob`.
|
||||
|
||||
Finally, we write the `Blob` to disk using [`Bun.write()`](https://bun.sh/docs/api/file-io#writing-files-bun-write).
|
||||
Finally, we write the `Blob` to disk using [`Bun.write()`](https://bun.com/docs/api/file-io#writing-files-bun-write).
|
||||
|
||||
```ts-diff#index.ts
|
||||
const server = Bun.serve({
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: Hot reload an HTTP server
|
||||
---
|
||||
|
||||
Bun supports the [`--hot`](https://bun.sh/docs/runtime/hot#hot-mode) flag to run a file with hot reloading enabled. When any module or file changes, Bun re-runs the file.
|
||||
Bun supports the [`--hot`](https://bun.com/docs/runtime/hot#hot-mode) flag to run a file with hot reloading enabled. When any module or file changes, Bun re-runs the file.
|
||||
|
||||
```sh
|
||||
$ bun --hot run index.ts
|
||||
|
||||
@@ -4,7 +4,7 @@ name: Common HTTP server usage
|
||||
|
||||
This starts an HTTP server listening on port `3000`. It demonstrates basic routing with a number of common responses and also handles POST data from standard forms or as JSON.
|
||||
|
||||
See [`Bun.serve`](https://bun.sh/docs/api/http) for details.
|
||||
See [`Bun.serve`](https://bun.com/docs/api/http) for details.
|
||||
|
||||
```ts
|
||||
const server = Bun.serve({
|
||||
|
||||
@@ -4,7 +4,7 @@ name: Write a simple HTTP server
|
||||
|
||||
This starts an HTTP server listening on port `3000`. It responds to all requests with a `Response` with status `200` and body `"Welcome to Bun!"`.
|
||||
|
||||
See [`Bun.serve`](https://bun.sh/docs/api/http) for details.
|
||||
See [`Bun.serve`](https://bun.com/docs/api/http) for details.
|
||||
|
||||
```ts
|
||||
const server = Bun.serve({
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: Stream a file as an HTTP Response
|
||||
---
|
||||
|
||||
This snippet reads a file from disk using [`Bun.file()`](https://bun.sh/docs/api/file-io#reading-files-bun-file). This returns a `BunFile` instance, which can be passed directly into the `new Response` constructor.
|
||||
This snippet reads a file from disk using [`Bun.file()`](https://bun.com/docs/api/file-io#reading-files-bun-file). This returns a `BunFile` instance, which can be passed directly into the `new Response` constructor.
|
||||
|
||||
```ts
|
||||
const path = "/path/to/file.txt";
|
||||
@@ -30,7 +30,7 @@ new Response(Bun.file("./img.png")).headers.get("Content-Type");
|
||||
|
||||
---
|
||||
|
||||
Putting it all together with [`Bun.serve()`](https://bun.sh/docs/api/http#bun-serve).
|
||||
Putting it all together with [`Bun.serve()`](https://bun.com/docs/api/http#bun-serve).
|
||||
|
||||
```ts
|
||||
// static file server
|
||||
@@ -45,4 +45,4 @@ Bun.serve({
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > File I/O](https://bun.sh/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.
|
||||
See [Docs > API > File I/O](https://bun.com/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: Configure TLS on an HTTP server
|
||||
---
|
||||
|
||||
Set the `tls` key to configure TLS. Both `key` and `cert` are required. The `key` should be the contents of your private key; `cert` should be the contents of your issued certificate. Use [`Bun.file()`](https://bun.sh/docs/api/file-io#reading-files-bun-file) to read the contents.
|
||||
Set the `tls` key to configure TLS. Both `key` and `cert` are required. The `key` should be the contents of your private key; `cert` should be the contents of your issued certificate. Use [`Bun.file()`](https://bun.com/docs/api/file-io#reading-files-bun-file) to read the contents.
|
||||
|
||||
```ts
|
||||
const server = Bun.serve({
|
||||
|
||||
@@ -23,4 +23,4 @@ This will add the package to `devDependencies` in `package.json`.
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.sh/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -33,4 +33,4 @@ $ bun add github:colinhacks/zod
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.sh/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -22,4 +22,4 @@ This will add the package to `optionalDependencies` in `package.json`.
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.sh/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -40,4 +40,4 @@ Running `bun install` will install peer dependencies by default, unless marked o
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.sh/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -30,4 +30,4 @@ import { z } from "zod";
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.sh/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -39,4 +39,4 @@ $ bun add zod@next
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.sh/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -26,7 +26,7 @@ password = "$NPM_PASSWORD"
|
||||
|
||||
---
|
||||
|
||||
Then assign your Azure Personal Access Token to the `NPM_PASSWORD` environment variable. Bun [automatically reads](https://bun.sh/docs/runtime/env) `.env` files, so create a file called `.env` in your project root. There is no need to base-64 encode this token! Bun will do this for you.
|
||||
Then assign your Azure Personal Access Token to the `NPM_PASSWORD` environment variable. Bun [automatically reads](https://bun.com/docs/runtime/env) `.env` files, so create a file called `.env` in your project root. There is no need to base-64 encode this token! Bun will do this for you.
|
||||
|
||||
```txt#.env
|
||||
NPM_PASSWORD=<paste token here>
|
||||
|
||||
@@ -18,7 +18,7 @@ registry = "https://username:password@registry.npmjs.org"
|
||||
|
||||
---
|
||||
|
||||
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](https://bun.sh/docs/runtime/env) for more information.
|
||||
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](https://bun.com/docs/runtime/env) for more information.
|
||||
|
||||
```toml#bunfig.toml
|
||||
[install]
|
||||
@@ -27,4 +27,4 @@ registry = { url = "https://registry.npmjs.org", token = "$npm_token" }
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.sh/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Configure git to diff Bun's lockb lockfile
|
||||
---
|
||||
|
||||
{% callout %}
|
||||
Bun v1.1.39 introduced `bun.lock`, a JSONC formatted lockfile. `bun.lock` is human-readable and git-diffable without configuration, at no cost to performance. [**Learn more.**](https://bun.sh/docs/install/lockfile#text-based-lockfile)
|
||||
Bun v1.1.39 introduced `bun.lock`, a JSONC formatted lockfile. `bun.lock` is human-readable and git-diffable without configuration, at no cost to performance. [**Learn more.**](https://bun.com/docs/install/lockfile#text-based-lockfile)
|
||||
{% /callout %}
|
||||
|
||||
---
|
||||
|
||||
@@ -20,4 +20,4 @@ z.string();
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.sh/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: Configure a private registry for an organization scope with bun install
|
||||
---
|
||||
|
||||
Private registries can be configured using either [`.npmrc`](https://bun.sh/docs/install/npmrc) or [`bunfig.toml`](https://bun.sh/docs/runtime/bunfig#install-registry). While both are supported, we recommend using **bunfig.toml** for enhanced flexibility and Bun-specific options.
|
||||
Private registries can be configured using either [`.npmrc`](https://bun.com/docs/install/npmrc) or [`bunfig.toml`](https://bun.com/docs/runtime/bunfig#install-registry). While both are supported, we recommend using **bunfig.toml** for enhanced flexibility and Bun-specific options.
|
||||
|
||||
To configure a registry for a particular npm scope:
|
||||
|
||||
@@ -26,7 +26,7 @@ To configure a registry for a particular npm scope:
|
||||
|
||||
---
|
||||
|
||||
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](https://bun.sh/docs/runtime/env) for more information.
|
||||
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](https://bun.com/docs/runtime/env) for more information.
|
||||
|
||||
```toml#bunfig.toml
|
||||
[install.scopes]
|
||||
@@ -35,4 +35,4 @@ Your `bunfig.toml` can reference environment variables. Bun automatically loads
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.sh/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -43,4 +43,4 @@ $ bun install
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager > Trusted dependencies](https://bun.sh/docs/install/lifecycle) for complete documentation of trusted dependencies.
|
||||
See [Docs > Package manager > Trusted dependencies](https://bun.com/docs/install/lifecycle) for complete documentation of trusted dependencies.
|
||||
|
||||
@@ -67,4 +67,4 @@ $ bun add zod
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.sh/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Generate a yarn-compatible lockfile
|
||||
---
|
||||
|
||||
{% callout %}
|
||||
Bun v1.1.39 introduced `bun.lock`, a JSONC formatted lockfile. `bun.lock` is human-readable and git-diffable without configuration, at no cost to performance. [**Learn more.**](https://bun.sh/docs/install/lockfile#text-based-lockfile)
|
||||
Bun v1.1.39 introduced `bun.lock`, a JSONC formatted lockfile. `bun.lock` is human-readable and git-diffable without configuration, at no cost to performance. [**Learn more.**](https://bun.com/docs/install/lockfile#text-based-lockfile)
|
||||
{% /callout %}
|
||||
|
||||
---
|
||||
@@ -41,4 +41,4 @@ abab@^2.0.6:
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.sh/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -13,4 +13,4 @@ process.on("SIGINT", () => {
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Utils](https://bun.sh/docs/api/utils) for more useful utilities.
|
||||
See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: Spawn a child process and communicate using IPC
|
||||
---
|
||||
|
||||
Use [`Bun.spawn()`](https://bun.sh/docs/api/spawn) to spawn a child process. When spawning a second `bun` process, you can open a direct inter-process communication (IPC) channel between the two processes.
|
||||
Use [`Bun.spawn()`](https://bun.com/docs/api/spawn) to spawn a child process. When spawning a second `bun` process, you can open a direct inter-process communication (IPC) channel between the two processes.
|
||||
|
||||
{%callout%}
|
||||
**Note** — This API is only compatible with other `bun` processes. Use `process.execPath` to get a path to the currently running `bun` executable.
|
||||
@@ -63,4 +63,4 @@ process.send({ message: "Hello from child as object" });
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Child processes](https://bun.sh/docs/api/spawn) for complete documentation.
|
||||
See [Docs > API > Child processes](https://bun.com/docs/api/spawn) for complete documentation.
|
||||
|
||||
@@ -10,4 +10,4 @@ Bun.nanoseconds();
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Utils](https://bun.sh/docs/api/utils) for more useful utilities.
|
||||
See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities.
|
||||
|
||||
@@ -36,4 +36,4 @@ process.on("exit", code => {
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Utils](https://bun.sh/docs/api/utils) for more useful utilities.
|
||||
See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: Read stderr from a child process
|
||||
---
|
||||
|
||||
When using [`Bun.spawn()`](https://bun.sh/docs/api/spawn), the child process inherits the `stderr` of the spawning process. If instead you'd prefer to read and handle `stderr`, set the `stderr` option to `"pipe"`.
|
||||
When using [`Bun.spawn()`](https://bun.com/docs/api/spawn), the child process inherits the `stderr` of the spawning process. If instead you'd prefer to read and handle `stderr`, set the `stderr` option to `"pipe"`.
|
||||
|
||||
```ts
|
||||
const proc = Bun.spawn(["echo", "hello"], {
|
||||
@@ -28,4 +28,4 @@ if (errors) {
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Child processes](https://bun.sh/docs/api/spawn) for complete documentation.
|
||||
See [Docs > API > Child processes](https://bun.com/docs/api/spawn) for complete documentation.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: Read stdout from a child process
|
||||
---
|
||||
|
||||
When using [`Bun.spawn()`](https://bun.sh/docs/api/spawn), the `stdout` of the child process can be consumed as a `ReadableStream` via `proc.stdout`.
|
||||
When using [`Bun.spawn()`](https://bun.com/docs/api/spawn), the `stdout` of the child process can be consumed as a `ReadableStream` via `proc.stdout`.
|
||||
|
||||
```ts
|
||||
const proc = Bun.spawn(["echo", "hello"]);
|
||||
@@ -23,4 +23,4 @@ const proc = Bun.spawn(["echo", "hello"], {
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Child processes](https://bun.sh/docs/api/spawn) for complete documentation.
|
||||
See [Docs > API > Child processes](https://bun.com/docs/api/spawn) for complete documentation.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: Spawn a child process
|
||||
---
|
||||
|
||||
Use [`Bun.spawn()`](https://bun.sh/docs/api/spawn) to spawn a child process.
|
||||
Use [`Bun.spawn()`](https://bun.com/docs/api/spawn) to spawn a child process.
|
||||
|
||||
```ts
|
||||
const proc = Bun.spawn(["echo", "hello"]);
|
||||
@@ -38,4 +38,4 @@ output; // => "hello\n"
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Child processes](https://bun.sh/docs/api/spawn) for complete documentation.
|
||||
See [Docs > API > Child processes](https://bun.com/docs/api/spawn) for complete documentation.
|
||||
|
||||
@@ -51,4 +51,4 @@ Chunk: hello
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Utils](https://bun.sh/docs/api/utils) for more useful utilities.
|
||||
See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities.
|
||||
|
||||
@@ -25,4 +25,4 @@ bytes.length;
|
||||
|
||||
---
|
||||
|
||||
Refer to the [Typed arrays](https://bun.sh/docs/api/binary-data#typedarray) docs for more information on working with typed arrays in Bun.
|
||||
Refer to the [Typed arrays](https://bun.com/docs/api/binary-data#typedarray) docs for more information on working with typed arrays in Bun.
|
||||
|
||||
@@ -16,4 +16,4 @@ const buffer = Buffer.from(arrbuf);
|
||||
|
||||
---
|
||||
|
||||
Refer to [Binary data > Buffer](https://bun.sh/docs/api/binary-data#buffer) for more information on working with `Buffer` and other binary data formats in Bun.
|
||||
Refer to [Binary data > Buffer](https://bun.com/docs/api/binary-data#buffer) for more information on working with `Buffer` and other binary data formats in Bun.
|
||||
|
||||
@@ -13,4 +13,4 @@ await file.exists(); // boolean;
|
||||
|
||||
---
|
||||
|
||||
Refer to [API > File I/O](https://bun.sh/docs/api/file-io) for more information on working with `BunFile`.
|
||||
Refer to [API > File I/O](https://bun.com/docs/api/file-io) for more information on working with `BunFile`.
|
||||
|
||||
@@ -17,4 +17,4 @@ file.type; // image/png
|
||||
|
||||
---
|
||||
|
||||
Refer to [API > File I/O](https://bun.sh/docs/api/file-io) for more information on working with `BunFile`.
|
||||
Refer to [API > File I/O](https://bun.com/docs/api/file-io) for more information on working with `BunFile`.
|
||||
|
||||
@@ -23,4 +23,4 @@ for await (const chunk of stream) {
|
||||
|
||||
---
|
||||
|
||||
Refer to the [Streams](https://bun.sh/docs/api/streams) documentation for more information on working with streams in Bun.
|
||||
Refer to the [Streams](https://bun.com/docs/api/streams) documentation for more information on working with streams in Bun.
|
||||
|
||||
@@ -18,4 +18,4 @@ byteArray.length; // length of byteArray
|
||||
|
||||
---
|
||||
|
||||
Refer to [API > Binary data > Typed arrays](https://bun.sh/docs/api/binary-data#typedarray) for more information on working with `Uint8Array` and other binary data formats in Bun.
|
||||
Refer to [API > Binary data > Typed arrays](https://bun.com/docs/api/binary-data#typedarray) for more information on working with `Uint8Array` and other binary data formats in Bun.
|
||||
|
||||
@@ -65,4 +65,4 @@ process.on("SIGINT", () => {
|
||||
|
||||
---
|
||||
|
||||
Refer to [API > Binary data > Typed arrays](https://bun.sh/docs/api/binary-data#typedarray) for more information on working with `Uint8Array` and other binary data formats in Bun.
|
||||
Refer to [API > Binary data > Typed arrays](https://bun.com/docs/api/binary-data#typedarray) for more information on working with `Uint8Array` and other binary data formats in Bun.
|
||||
|
||||
@@ -34,4 +34,4 @@ try {
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > FileSystem](https://bun.sh/docs/api/file-io) for more filesystem operations.
|
||||
See [Docs > API > FileSystem](https://bun.com/docs/api/file-io) for more filesystem operations.
|
||||
|
||||
@@ -16,4 +16,4 @@ const exists = await file.exists();
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > FileSystem](https://bun.sh/docs/api/file-io) for more filesystem operations.
|
||||
See [Docs > API > FileSystem](https://bun.com/docs/api/file-io) for more filesystem operations.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user