Sign in

Bun

@bun.sh
3.6K followers 1 following 52 posts

Bun is a fast, all-in-one toolkit for installing, bundling, running and testing JavaScript & TypeScript. To install Bun: ``` curl bun.sh/install | bash -s ``` bun.sh

PostsRepliesMedia
Bun @bun.sh · 29/08/2025
30 days until Bun v1.3
4561
Bun @bun.sh · 28/05/2025
Bun v1.2.15
2672
Bun @bun.sh · 05/05/2025
Bun v1.2.12
Stream browser console. log to terminal
Memory
272 MB
OLD
150 мв
NEW
Hot reloads with lucide-react (307 reloads)
[browser)
Hello!
Node.js
Compatibility
98.4% of timers tests pass
node,js
3683
Bun @bun.sh · 05/04/2025
In the next version of Bun & Safari Polymorphic array access gets up to 8x faster, thanks to @yusukesuzuki.bsky.social
mport { run, bench } from "mitata";

// Assuming the vectors are of the same length
function cosineDistance(a, b) {
  let dotProduct = 0;
  let magA = 0;
  let magB = 0;
  for (let i = 0; i < a.length; i++) {
    dotProduct += a[i] * b[i];
    magA += a[i] * a[i];
    magB += b[i] * b[i];
  }
  return 1 - dotProduct / (Math.sqrt(magA) * Math.sqrt(magB));
}

// Generate random data for testing
const dimensions = 1536; // Adjust dimensions as needed
const array1 = Array.from({ length: dimensions }, () => Math.random() * 100);
const array2 = Array.from({ length: dimensions }, () => Math.random() * 100);
const floatArray1 = new Float32Array(array1);
const floatArray2 = new Float32Array(array2);

bench("Array", () => {
  cosineDistance(array1, array2);
});

bench("Float32Array", () => {
  cosineDistance(floatArray1, floatArray2);
});

await run();
bun-latest array.mjs # New
clk: ~3.94 GHz
cpu: Apple M3 Max
runtime: bun 1.2.9 (arm64-darwin)

benchmark                   avg (min … max)
-------------------------------------------
Array                          1.07 µs/iter   1.07 µs  ▇▃ ▄█▂
                        (1.06 µs … 1.13 µs)   1.09 µs ▄██▆███▇▅▄▄▄▂▂▂▁▁▁▁▂▂
Float32Array                   1.64 µs/iter   1.64 µs                   █
                        (1.46 µs … 1.68 µs)   1.67 µs ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁██▃▁
bun-1.2.8 array.mjs # Prev
clk: ~3.87 GHz
cpu: Apple M3 Max
runtime: bun 1.2.8 (arm64-darwin)

benchmark                   avg (min … max)
-------------------------------------------
Array                          1.07 µs/iter   1.07 µs  ▄  █▂
                        (1.06 µs … 1.11 µs)   1.10 µs ▅█▆▆██▄▄▅▂▁▁▁▂▂▁▁▁▁▁▁
Float32Array                  13.52 µs/iter  13.50 µs  █   █
                      (13.41 µs … 14.02 µs)  13.59 µs ██▁▁▁███▁██▁▁▁▁▁▁▁▁██
node array.mjs # Node, for comparison
clk: ~3.94 GHz
cpu: Apple M3 Max
runtime: node 23.10.0 (arm64-darwin)

benchmark                   avg (min … max)
-------------------------------------------
Array
1353
Bun @bun.sh · 31/03/2025
Bun v1.2.8 - Fixes 18 bugs (addressing 18 👍) - napi perf improvement for integers - 2x faster headers.get() - node:http & node:fs bugfixes - `bun install --frozen-lockfile` + `overrides` fix - `bun pack` directory-specific ignores Full release notes below
1582
Bun @bun.sh · 27/03/2025
Bun v1.2.7 - Fixes 35 bugs (addressing 219 👍) - Builtin request.cookies.set & get in Bun.serve() routes - Fixed TypeScript type definitions conflicts with `@types/node` & libdom - Bugfixes for node:http, node:vm Thanks to 13 contributors! Full release notes below
2583
Bun @bun.sh · 26/03/2025
2332
Bun @bun.sh · 11/02/2025
The above is a TailwindCSS + shadcn/ui Twitter frontend clone demo app. This is hot reloading css & js/ts/tsx, running a tailwindcss plugin, transpiling jsx/tsx, websocket hmr happening live as you type.
0110
Bun @bun.sh · 11/02/2025
In the next version of Bun Bun.serve() gets builtin support for hot reloading frontend applications.
31329
Bun @bun.sh · 17/01/2025
many such cases
Fucking hell, bun is so fast
1
It's out of this world fast
What kind of black magic is this haha
I got expo working with bun
Literally 10min of work lol
1230
Bun @bun.sh · 17/01/2025
Add a React frontend to your Express app in 7 lines of code with Bun
mport useStatic from "bun-use-static";
import app from "./my-express-app";
import mySinglePageApp from "./dashboard.html";

// Get the node:http Server from calling app.listen()
const server = app.listen(3000, () => {
  console.log(`Example app listening on port 3000`);
});

useStatic(server, {
  "/dashboard": mySinglePageApp,
});
2665
Bun @bun.sh · 29/12/2024
The API is designed to work very similarly to Response, Blob, and Bun.file(path), so you can read from S3 just like from the local filesystem or fetch().
0140
Bun @bun.sh · 29/12/2024
When you pass `new Response` an S3 file, it turns into a redirect to a presigned expiring URL so that you don't waste your server's resources downloading to S3 and sending to the user
1160
Bun @bun.sh · 29/12/2024
In the next version of Bun Bun gets first-class support for S3. Upload, download, stream, and presign with 0 dependencies
import { s3, file, write } from "bun";

const svg = s3("logo.svg", {
  accessKeyId: process.env.S3_ACCESS_KEY,
  secretAccessKey: process.env.S3_SECRET_KEY,
  endpoint: process.env.S3_ENDPOINT,
  bucket: process.env.S3_BUCKET,
});

// Upload a local file to S3
await write(svg, file("./logo.svg"));

// Download from S3 as text 
const text = await svg.text();
// or .json(), .bytes(), etc

// Presign a URL
const url = svg.presign();
console.log(url);
51108
Bun @bun.sh · 16/12/2024
1240
Bun @bun.sh · 11/12/2024
Merge conflicts are inevitable, and that's why we put each package and it's dependencies on a single line. Fewer lines means easier merge conflicts.
1150
Bun @bun.sh · 11/12/2024
Unlike bun.lockb, this lockfile is human readable, which is important when working in teams The lockfile format is jsonc, like tsconfig.json. Trailing commas and comments are allowed.
290
Bun @bun.sh · 11/12/2024
In the next version of Bun `bun.lock` is the new lockfile in `bun install`
/tmp/nexty
❯ rm -rf bun.lockb

/tmp/nexty
❯ bun install --save-text-lockfile # text-based lockfile
bun install v1.1.39 (b55ca429)

Checked 35 installs across 60 packages (no changes) [9.00ms]

/tmp/nexty
❯ cat bun.lock -l json --no-paging
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: bun.lock
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ {
   2   │   "lockfileVersion": 0,
   3   │   "workspaces": {
   4   │     "": {
   5   │       "dependencies": {
   6   │         "next": "^15.1.0"
   7   │       },
   8   │       "devDependencies": {
   9   │         "@types/bun": "latest"
  10   │       }
  11   │     }
  12   │
5777
Bun @bun.sh · 09/11/2024
what’s stopping you from switching to bun
Bunny bun bun bun bun
6321
Bun @bun.sh · 04/11/2024
> Bun has definitely lived up to the hype ❤️
I now use it as at least a package manager on every project; So install command will be `bun i` but commands to run the application will still use node `node dist/server.js` or npm `npm run dev`. This has saved us 1000's of dollars in CI bills because installing modules has gone from like 20s to 2s on some projects. Infact it's so fast that it's slower to use CircleCI's node_modules caching than it is to just do a fresh install.
Use it as a server runtime in one project, this has been a near seamless experience with minor incompatibilities early on that have now been fixed (Some GraphQL packages would throw runtime errors).
Use it as a test runner on the projects that use it as a server runtime. Seamless experience and insanley fast.
Bun has definitely lived up to the hype, you can feel the performance difference regardless of what any benchmark shows. I feel like some of the latest ones trying to prove they're as fast or faster than Bun are purposely lieing. I.E there's a benchmark between encore.dev with bun and bun directly, and they say encore is faster. This I strongly suspect isn't correct as they're comparing encore.dev's rust runtime which utilizes multiple threads against a default configuration of bun which wouldn't.

If they change their benchmark on github to use https://bun.sh/guides/http/cluster which is only available on linux I have a feeling Bun would shred encore.dev
1344