import CodeBlock from "../components/CodeBlock"; const Command = ({ children, href, Tag = href ? "a" : "span" }) => ( {children} ); const WebAPI = ({ children, href, Tag = href ? "a" : "span" }) => ( {children} ); const NodeJS = ({ children, href, Tag = href ? "a" : "span" }) => ( {children} ); const TypeScript = ({ children, href, Tag = href ? "a" : "span" }) => ( {children} ); const React = ({ children, href, Tag = href ? "a" : "span" }) => ( {children} ); const Bun = ({ children, href, Tag = href ? "a" : "span" }) => ( {children} ); const fmt = new Intl.NumberFormat(); const Label = ({ children, replace }) => { if (replace) { return (
{replace}
{children}
); } return
{children}
; }; const BarGraphItem = ({ type, amount = 0, label, max = 0 }) => (
  • {`${type}: ${fmt.format( amount, )} ${label}`}
    {fmt.format(amount)}
  • ); const BarGraphLabel = ({ name, version, source }) => (
    {name}
    {version}
    View source
    ); const PerformanceClaim = ({ href, children }) => ( {children} ); const Zig = () => ( Zig ); const InstallBox = ({ desktop = false }) => (
    Install Bun CLI {process.versions.bun} (beta)
    macOS x64 & Silicon, Linux x64, Windows Subsystem for Linux
    curl -fsSL https://bun.sh/install | bash
    Show script source
    ); const Group = ({ children, ...props }) => (
    {children}
    ); export default function LandingPage() { return ( <>

    Bun is a fast all-in-one JavaScript runtime

    Bundle, transpile, install and run JavaScript & TypeScript projects — all in Bun. Bun is a new JavaScript runtime with a native bundler, transpiler, task runner and npm client built-in.

    Server-side rendering React

    HTTP requests per second (Linux x64)

    WebSocket chat server

    Messages sent per second (Linux x64, 16 clients)

    Load a huge table

    Average queries per second

    Tell me more about Bun

    Bun is a modern JavaScript runtime like Node or Deno. It was built from scratch to focus on three main things:

    Bun is designed as a drop-in replacement for your current JavaScript & TypeScript apps or scripts — on your local computer, server or on the edge. Bun natively implements hundreds of Node.js and Web APIs, including ~90% of{" "} Node-API {" "} functions (native modules), fs, path, Buffer and more.

    The goal of Bun is to run most of the world's JavaScript outside of browsers, bringing performance and complexity enhancements to your future infrastructure, as well as developer productivity through better, simpler tooling.

    Batteries included

    How does Bun work?

    Bun uses the{" "} JavaScriptCore {" "} engine, which tends{" "} to start {" "} and perform a little faster than more traditional choices like V8. Bun is written in{" "} , a low-level programming language with manual memory management.

    Most of Bun is written from scratch including the JSX/TypeScript transpiler, npm client, bundler, SQLite client, HTTP client, WebSocket client and more.

    Why is Bun fast?

    An enormous amount of time spent profiling, benchmarking and optimizing things. The answer is different for every part of Bun, but one general theme:{" "} 's low-level control over memory and lack of hidden control flow makes it much simpler to write fast software.{" "} Sponsor the Zig Software Foundation .

    Getting started

    To install Bun, run this{" "} install script {" "} in your terminal. It downloads Bun from GitHub.

    {` curl -fsSL https://bun.sh/install | bash `}

    {" "} Bun's HTTP server is built on web standards like{" "} Request {" "} and{" "} Response

    {` // http.js export default { port: 3000, fetch(request) { return new Response("Welcome to Bun!"); }, }; `}

    Run it with Bun:

    {`bun run http.js`}

    Then open{" "} http://localhost:3000 {" "} in your browser.

    See{" "} more examples {" "} and check out{" "} the docs. If you have any questions or want help, join{" "} Bun's Discord.

    Bun CLI

    bun run

    The same command for running JavaScript & TypeScript files with bun's JavaScript runtime also runs package.json{" "} "scripts".

    Replace npm run with{" "} bun run and save 160ms on every run.
    Bun runs package.json scripts{" "} 30x faster than npm run
    {" "}
    bun install

    bun install is an npm-compatible package manager. You probably will be surprised by how much faster copying files can get.

    Replace yarn with{" "} bun install and get 20x faster package installs.
    bun install uses the fastest system calls available to copy files.
    bun wiptest

    A Jest-like test runner for JavaScript & TypeScript projects built-in to Bun.

    What is the license?

    MIT License, excluding dependencies which have various licenses.

    How do I see the source code?

    Bun is on GitHub.