Skip to content

Bun

May 22, 2026
March 14, 2023

Fast *all-in-one* JavaScript runtime

Bun - fast JavaScript & CSS bundler
oven-sh/bun: Incredibly fast JavaScript runtime, bundler, transpiler and package manager – all in one.

NextJS Was Too Slow...So He Made Bun??! Jarred Sumner & The Story Of Bun - YouTube Theo's interview
Getting started with Bun and React - LogRocket Blog
Let's create a next.js app with bun - DEV Community
Bun vs. Node.js | refine

Bun 1.0 | Bun Blog 2023-09
Bun 1.0 is here - YouTube
Bun Is Better Than I Hoped - YouTube Theo

npm install -g bun
curl -fsSL https://bun.sh/install | bash

bunx bun-repl

bun init
bun create new-template-name ./app

# package management
bun pm ls
bun install <package>
bun add <package>

SFNode Meetup: Bun with Jarred Sumner - YouTube
JS FASTER THAN RUST??? (Probably not but still) HOW IS BUN SO FAST - YouTube

Rust rewrite

Bun version 1.3.14 is expected to be the final release based on Zig

Bun was acquired by Anthropic late 2025, used Claude Code to rewrite Bun from Zug to Rust, citing Zig's slow build time, memory leaks and not accepting AI code as issue.
The generated Rust code was not idiomatic and full of unsafe blocks.

Bun Was Rewritten in Rust. But the Code... - YouTube
I wish this was clickbait - YouTube

Comparison

Bun, Node, and Deno: What's the Difference? - YouTube
Bun: The JavaScript runtime taking on Node.js and Deno - LogRocket Blog
A first look at Bun: is it really 3x faster than Node.js and Deno? - DEV Community
Node.js vs Deno vs Bun: A re-look at the performance when serving images | The JS runtimes
Bun vs. Node.js | refine

Bundler

The Bun Bundler | Bun Blog
Bundler - Bun

Single-file executable

Single-file executable - Bun

bun build --compile --minify --sourcemap ./path/to/my/app.ts --outfile myapp
#  improve startup time
bun build --compile --minify --sourcemap --bytecode ./path/to/my/app.ts --outfile myapp

Single-file executable - Bun web server plus assets

Including binaries

  1. Bundle your application
    Use bun build to compile your JS/TS into an executable while specifying the external native binaries you want to exclude from the core bundle (so they remain referenced). 
  2. Embed files at build time
    Use Bun’s built-in embeddedFiles array to bundle the binary directly into the generated executable.
  3. Extract at runtime
    Have your application's entry point extract the embedded binary to a temporary system directory (e.g., os.tmpdir()) every time the executable launches.
  4. Update the import path
    Point your library requiring the native module (like sharp or better-sqlite3) to this new temporary path.

"bun build" does not embed binaries from node_modules correctly · Issue #15374 · oven-sh/bun

import { file, write, $ } from "bun";
import { tmpdir } from "node:os";
import { join } from "node:path";

// Extract the embedded binary from the compiled executable
const tempDir = join(tmpdir(), "my-app-binaries");
const binaryPath = join(tempDir, "vendor-binary.node");

// embeddedFiles[0] represents the binary you bundled
await write(binaryPath, embeddedFiles[0]);

// Ensure execution permissions are set
await $`chmod 755 ${binaryPath}`;

// Load your library and force it to use the extracted binary
process.env.LIBRARY_BINARY_PATH = binaryPath;
import("./your-native-library.js");

Package Manager

Bun has builtin package manager

$ bun

  install                         Install dependencies for a package.json (bun i)
  add       @shumai/shumai        Add a dependency to package.json (bun a)
  link                            Link an npm package globally
  remove    backbone              Remove a dependency from package.json (bun rm)
  unlink                          Globally unlink an npm package
  pm                              More commands for managing packages

$ bun pm
bun pm - package manager related commands

  bun pm bin          print the path to bin folder
  bun pm -g bin       print the global path to bin folder
  bun pm ls           list the dependency tree according to the current lockfile
  bun pm ls --all     list the entire dependency tree according to the current lockfile
  bun pm hash         generate & print the hash of the current lockfile
  bun pm hash-string  print the string used to hash the lockfile
  bun pm hash-print   print the hash stored in the current lockfile
  bun pm cache        print the path to the cache folder
  bun pm cache rm     clear the cache

Ecosystem

apvarun/awesome-bun: ⚡️ A curated list of awesome things related to Bun

Node.js – Ecosystem | Bun Docs standard libraries are improving to match Node

theseyan/bkg: Package Bun apps into a single executable
Single-file executable – Runtime | Bun Docs

App Framework

#web-framework

Elysia - Fast, and friendly Bun web frameworks | Elysia.js tRPC, GQL, OpenAPI, JWT, type checks
The BETH Stack: Build Hypermedia-Driven Web Apps with Great DX and Performance - YouTube Bun, Elysia, Turso, HTMX + Typed HTML

Hono - Ultrafast web framework for the Edges

Buchta

Bun Crash Course 2023 with HTMX example - YouTube 2023-09

Packages

rgl/try-puppeteer-in-bun: try puppeteer in bun
Fix postinstall and finish trustedDependencies · Issue #4959 · oven-sh/bun trustedDependencies is a workaround for non-whitelisted packages
bun add puppeteer doesn't run postinstall script for trusted dependency · Issue #4705 · oven-sh/bun · GitHub

Workaround:
bunx @puppeteer/browsers install chrome@stable --path $HOME/.cache/puppeteer
and set PUPPETEER_EXECUTABLE_PATH in .env