Skip to content

Bun

November 22, 2023
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

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

Can this be used to build frontend app?

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

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