# Bun — All-in-One JavaScript Runtime > Fast JavaScript runtime, bundler, test runner, and package manager in one tool. Drop-in Node.js replacement. 88K+ GitHub stars. ## Install Save as a script file and run: # Bun — All-in-One JavaScript Runtime ## Quick Use ```bash curl -fsSL https://bun.sh/install | bash ``` ```bash # Run any JavaScript/TypeScript file bun run app.ts # Install packages (25x faster than npm) bun install express # Run tests bun test # Bundle for production bun build ./src/index.ts --outdir ./dist # Start a project bun init ``` ```typescript // server.ts - HTTP server in Bun const server = Bun.serve({ port: 3000, fetch(req) { return new Response("Hello from Bun!"); }, }); console.log(`Listening on http://localhost:${server.port}`); ``` ```bash bun run server.ts # Server starts in ~6ms ``` --- ## Intro Bun is an all-in-one JavaScript/TypeScript runtime with 88,700+ GitHub stars that replaces Node.js, npm, webpack, and Jest in a single tool. Written in Zig and powered by JavaScriptCore (Safari's engine), Bun starts 4x faster than Node.js, installs packages 25x faster than npm, and bundles code 1.5x faster than esbuild. It runs TypeScript and JSX natively without configuration, includes a built-in test runner, and is compatible with most Node.js packages. For AI developers, Bun means faster API servers, instant package installs, and zero-config TypeScript for AI application backends. Works with: JavaScript, TypeScript, JSX, Node.js packages (npm compatible), any JS framework. Best for developers who want a faster, simpler alternative to Node.js + npm + webpack + Jest. Setup time: under 1 minute. --- ## Bun Performance | Benchmark | Node.js | Bun | Speedup | |-----------|---------|-----|--------| | **Startup** | ~25ms | ~6ms | **4x** | | **npm install** | ~10s | ~0.4s | **25x** | | **HTTP requests/sec** | ~65K | ~105K | **1.6x** | | **Bundle (esbuild equiv)** | 1.0x | 1.5x | **1.5x** | | **TypeScript** | Needs ts-node | Native | **Zero config** | ### Package Manager ```bash # Install all dependencies (lockfile-aware) bun install # 25x faster than npm install # Add a package bun add openai bun add -d typescript # Remove bun remove express # Compatible with package.json and node_modules ``` ### Native TypeScript ```typescript // No tsconfig needed, no ts-node, no build step const response: Response = await fetch("https://api.openai.com/v1/models"); const data: { data: Array<{ id: string }> } = await response.json(); console.log(data.data.map(m => m.id)); ``` ```bash bun run app.ts # Just works ``` ### Built-in Test Runner ```typescript // app.test.ts import { expect, test } from "bun:test"; test("2 + 2 = 4", () => { expect(2 + 2).toBe(4); }); test("fetch works", async () => { const res = await fetch("https://httpbin.org/get"); expect(res.status).toBe(200); }); ``` ```bash bun test # Runs all .test.ts files ``` ### Built-in Bundler ```bash bun build ./src/index.ts --outdir ./dist --target browser ``` ### SQLite Built-in ```typescript import { Database } from "bun:sqlite"; const db = new Database("mydb.sqlite"); db.run("CREATE TABLE IF NOT EXISTS chats (id INTEGER PRIMARY KEY, prompt TEXT, response TEXT)"); db.run("INSERT INTO chats (prompt, response) VALUES (?, ?)", ["Hello", "Hi there!"]); ``` --- ## FAQ **Q: What is Bun?** A: Bun is an all-in-one JavaScript/TypeScript runtime with 88,700+ GitHub stars. It replaces Node.js (runtime), npm (package manager), webpack (bundler), and Jest (test runner) in a single fast tool. **Q: Is Bun compatible with Node.js?** A: Yes, Bun is largely compatible with Node.js APIs and npm packages. Most Express, Fastify, and Next.js apps work with Bun with minimal changes. **Q: Is Bun free?** A: Yes, open-source under MIT license. --- ## Source & Thanks > Created by [Oven](https://github.com/oven-sh). Licensed under MIT. > > [bun](https://github.com/oven-sh/bun) — ⭐ 88,700+ --- ## 快速使用 ```bash curl -fsSL https://bun.sh/install | bash bun run app.ts ``` --- ## 简介 Bun 是拥有 88,700+ GitHub stars 的一体化 JavaScript/TypeScript 运行时,集运行时、包管理器、打包器和测试运行器于一身。启动比 Node.js 快 4x,安装包比 npm 快 25x,原生支持 TypeScript。 --- ## 来源与感谢 > Created by [Oven](https://github.com/oven-sh). Licensed under MIT. > > [bun](https://github.com/oven-sh/bun) — ⭐ 88,700+ --- Source: https://tokrepo.com/en/workflows/615b3bf1-5ba3-47bd-99fd-e76dfdf2557d Author: Script Depot