PageSourceSearch

https://bun.sh/docs

html bun.sh collected 2026-09-24 08:26:23 UTC 102,642 bytes, 7 lines download raw bytes

1<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Welcome to Bun | Bun Docs</title><meta name="description" content="Bun is an all-in-one toolkit for developing modern JavaScript/TypeScript applications." data-head=""/><meta name="theme-color" media="(prefers-color-scheme: light)" content="#ffffff"/><meta name="theme-color" media="(prefers-color-scheme: dark)" content="#0d0a0c"/><meta property="og:site_name" content="Bun" data-head=""/><meta property="og:type" content="website" data-head=""/><meta property="og:title" content="Welcome to Bun | Bun Docs" data-head=""/><meta property="og:description" content="Bun is an all-in-one toolkit for developing modern JavaScript/TypeScript applications." data-head=""/><meta property="og:url" content="https://bun.com/docs" data-head=""/><meta property="og:image" content="https://bun.com/og/docs.png" data-head=""/><meta property="og:locale" content="en_US" data-head=""/><meta name="twitter:site" content="@bunjavascript" data-head=""/><meta name="twitter:card" content="summary_large_image" data-head=""/><meta data-pagefind-filter="section[content]" content="Docs"/><link rel="preload" href="/fonts/Archivo.var.woff2" as="font" type="font/woff2" crossorigin="anonymous"/><link rel="preload" href="/fonts/MartianMono.var.woff2" as="font" type="font/woff2" crossorigin="anonymous"/><link rel="stylesheet" href="/_assets/site-1fc3814b.css"/><link rel="modulepreload" href="/_assets/chunk-as3fpxpb.js"/><link rel="modulepreload" href="/_assets/chunk-e7xk0yn7.js"/><link rel="modulepreload" href="/_assets/chunk-mnqx55rn.js"/><link rel="modulepreload" href="/_assets/chunk-ptwqee6j.js"/><link rel="modulepreload" href="/_assets/chunk-sk34g2c4.js"/><link rel="modulepreload" href="/_assets/chunk-tq8dcrdp.js"/><link rel="modulepreload" href="/_assets/page-docs-index-693w1vxg.js"/><link rel="canonical" href="https://bun.com/docs" data-head=""/><link rel="alternate" type="application/rss+xml" title="Bun Blog" href="/rss.xml"/><link rel="alternate" type="text/markdown" href="/docs.md" data-head=""/><link rel="manifest" href="/manifest.json"/><link rel="icon" href="/favicon.ico" sizes="any"/><link rel="icon" href="/logo.svg" type="image/svg+xml"/><link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32x32.png"/><link rel="icon" type="image/png" sizes="192x192" href="/icons/icon-192x192.png"/><link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png"/>
1<script type="application/ld+json" data-head="">{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://bun.com/#organization","name":"Bun","url":"https://bun.com/","logo":{"@type":"ImageObject","url":"https://bun.com/logo-square.png","width":512,"height":512},"sameAs":["https://x.com/bunjavascript","https://github.com/oven-sh/bun","https://bun.com/discord"],"parentOrganization":{"@type":"Organization","name":"Anthropic, PBC","url":"https://www.anthropic.com"},"description":"A fast all-in-one JavaScript runtime and toolkit"},{"@type":"WebSite","@id":"https://bun.com/#website","name":"Bun","url":"https://bun.com/","publisher":{"@id":"https://bun.com/#organization"}},{"@type":"WebPage","@id":"https://bun.com/docs#webpage","url":"https://bun.com/docs","name":"Welcome to Bun | Bun Docs","description":"Bun is an all-in-one toolkit for developing modern JavaScript/TypeScript applications.","isPartOf":{"@id":"https://bun.com/#website"},"primaryImageOfPage":{"@type":"ImageObject","url":"https://bun.com/og/docs.png"},"inLanguage":"en"}]}</script>
1<script defer="" data-domain="bun.sh" src="https://plausible.io/js/script.js"></script>
1</head><body><div id="__bun"><div class="flex min-h-screen flex-col"><a href="#main" class="skip-link">Skip to content</a><header class="site-header sticky top-0 z-40 w-full"><div class="flex h-header items-center gap-6 px-gutter"><a aria-label="Bun — home" class="group/logo flex shrink-0 items-center gap-2.5" href="/" data-link="" data-prefetch="true"><img src="/logo.svg" alt="" width="40" height="35" class="h-[34px] w-auto transition-transform duration-300 ease-out group-hover/logo:-rotate-[10deg] group-active/logo:translate-y-px"/><svg viewBox="20 18 262 82" fill="currentColor" aria-hidden="true" class="h-[19px] w-auto text-fg"><path d="M68.014 97.942c-26.4 0-40.947-3.678-41.6-4.495a1050.447 1050.447 0 0 1 0-68.081c.653-.735 15.12-3.433 41.6-3.433 24.6 0 33.999 9.072 33.999 19.943 0 7.028-4.25 13.403-12.75 17.081v1.226c10.217.736 15.202 7.437 15.202 15.038 0 11.688-11.85 22.721-36.451 22.721ZM51.259 55.606l15.937.082c5.231-.817 8.746-3.678 8.746-8.091 0-5.558-4.169-8.582-11.606-8.582-6.375 0-11.197 1.062-12.995 2.452-.082 4.659-.082 9.48-.082 14.14Zm13.159 23.457c7.437 0 11.932-3.351 11.932-9.072 0-4.659-3.678-7.438-9.154-7.601l-15.937-.082c0 4.74 0 9.48.082 14.14 1.716 1.47 6.62 2.615 13.077 2.615Zm116.861-42.909c.654 19.86.654 38.74 0 58.192-7.519 1.226-15.528 1.226-23.047 0l-2.289-13.812h-1.471c-2.942 12.014-9.317 15.774-19.207 15.774-20.023 0-23.701-16.346-23.701-36.452 0-5.067.163-12.014.163-23.702a90.967 90.967 0 0 1 26.644 0V65.25c0 8.337 4.25 11.442 9.317 11.442 3.596 0 7.356-1.798 9.236-4.822V36.154a76.09 76.09 0 0 1 24.355 0Zm10.109 58.192c-.654-19.86-.654-38.74 0-58.192 7.519-1.226 15.528-1.226 23.048 0l2.288 13.813h1.471c2.942-12.014 9.317-15.774 19.207-15.774 20.024 0 23.701 16.346 23.701 36.451 0 5.068-.163 12.015-.163 23.702a90.974 90.974 0 0 1-26.644 0V65.25c0-8.336-4.25-11.442-9.317-11.442-3.596 0-7.356 1.798-9.236 4.822v35.716a76.095 76.095 0 0 1-24.355 0Z"></path></svg></a><nav aria-label="Primary" class="ml-2 hidden shrink-0 items-center gap-0.5 md:flex"><a aria-current="page" class="nav-link rounded-full px-3 py-1.5 text-[14.5px] font-medium text-fg-muted transition-colors hover:bg-subtle hover:text-fg" href="/docs" data-link="" data-prefetch="true">Docs</a><a class="nav-link rounded-full px-3 py-1.5 text-[14.5px] font-medium text-fg-muted transition-colors hover:bg-subtle hover:text-fg" href="/guides" data-link="" data-prefetch="true">Guides</a><a class="nav-link rounded-full px-3 py-1.5 text-[14.5px] font-medium text-fg-muted transition-colors hover:bg-subtle hover:text-fg" href="/reference" data-link="" data-prefetch="true">Reference</a><a class="nav-link rounded-full px-3 py-1.5 text-[14.5px] font-medium text-fg-muted transition-colors hover:bg-subtle hover:text-fg" href="/blog" data-link="" data-prefetch="true">Blog</a></nav><div class="flex min-w-0 flex-1 items-center justify-end md:justify-start md:pl-2"><button type="button" class="group hidden h-9 w-full min-w-0 max-w-[26rem] items-center gap-2.5 border border-line bg-canvas px-3 text-left text-[13.5px] text-fg-faint hover:border-rule md:flex" aria-label="Search"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-4 w-4"><path d="M7 3h6l4 4v6l-4 4H7l-4-4V7z"></path><path d="M15.5 15.5L21 21"></path></svg><span class="flex-1 truncate">Search docs, APIs, guides…</span><kbd aria-label="Slash" class="readout inline-flex h-[18px] min-w-[18px] items-center justify-center gap-[3px] border border-line px-1 text-[10.5px] leading-none text-fg-faint"><span>/</span></kbd></button><button type="button" aria-label="Search" class="inline-flex h-10 w-10 items-center justify-center border border-rule text-fg md:hidden"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-[18px] w-[18px]"><path d="M7 3h6l4 4v6l-4 4H7l-4-4V7z"></path><path d="M15.5 15.5L21 21"></path></svg></button></div><div class="hidden shrink-0 items-center gap-1 md:flex"><a aria-label="GitHub" class="inline-flex h-9 w-9 items-center justify-center rounded-full text-fg-muted transition-colors hover:bg-subtle hover:text-fg" href="https://github.com/oven-sh/bun" data-link="" data-prefetch="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-[18px] w-[18px]"><path d="M9.5 21v-3.5l1-1.5C7 15.5 5 14 5 10.5L6.5 8 6 4.5l3.5 1.5h5l3.5-1.5-.5 3.5 1.5 2.5c0 3.5-2 5-5.5 5.5l1 1.5V21"></path><path d="M9.5 18.5H7l-1.5-2L4 15.5"></path><rect x="8.5" y="9.75" width="1.75" height="2.25" fill="currentColor" stroke="none"></rect><rect x="13.75" y="9.75" width="1.75" height="2.25" fill="currentColor" stroke="none"></rect></svg></a><a aria-label="Discord" class="inline-flex h-9 w-9 items-center justify-center rounded-full text-fg-muted transition-colors hover:bg-subtle hover:text-fg" href="/discord" data-link="" data-prefetch="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-[18px] w-[18px]"><path d="M8 4.5l1 2h6l1-2 4 1.5 1.5 7-1.5 5-3.5 1.5-1.5-2h-6l-1.5 2L4 18l-1.5-5L4 6z"></path><path d="M8.5 16.5c1 .5 2.25.75 3.5.75s2.5-.25 3.5-.75"></path><rect x="7.5" y="10" width="2.5" height="3.25" fill="currentColor" stroke="none"></rect><rect x="14" y="10" width="2.5" height="3.25" fill="currentColor" stroke="none"></rect></svg></a><a class="group/btn cut relative inline-flex select-none items-center justify-center gap-2.5 whitespace-nowrap font-semibold [font-stretch:100%] tracking-[-0.005em] transition-none active:translate-y-
1px h-9 px-3.5 text-[13.5px] [--cut:7px] bg-fg text-canvas hover:bg-accent hover:text-white ml-1" href="/get" data-link="" data-prefetch="true">Install</a></div><div class="flex items-center gap-2 md:hidden"><button type="button" aria-label="Open menu" aria-expanded="false" aria-controls="mobile-menu" data-slider-open="mobile-menu" class="inline-flex h-10 w-10 items-center justify-center border border-rule text-fg"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-5 w-5"><path d="M4 6h16"></path><path d="M4 12h16"></path><path d="M4 18h16"></path></svg></button></div></div></header><div id="mobile-menu" data-slider="mobile-menu" class="slider-menu fixed inset-0 z-50 flex flex-col bg-canvas md:hidden" aria-hidden="true" inert=""><div class="flex h-header items-center justify-between px-gutter"><a aria-label="Bun — home" class="group/logo flex shrink-0 items-center gap-2.5" href="/" data-link="" data-prefetch="true"><img src="/logo.svg" alt="" width="40" height="35" class="h-[34px] w-auto transition-transform duration-300 ease-out group-hover/logo:-rotate-[10deg] group-active/logo:translate-y-px"/><svg viewBox="20 18 262 82" fill="currentColor" aria-hidden="true" class="h-[19px] w-auto text-fg"><path d="M68.014 97.942c-26.4 0-40.947-3.678-41.6-4.495a1050.447 1050.447 0 0 1 0-68.081c.653-.735 15.12-3.433 41.6-3.433 24.6 0 33.999 9.072 33.999 19.943 0 7.028-4.25 13.403-12.75 17.081v1.226c10.217.736 15.202 7.437 15.202 15.038 0 11.688-11.85 22.721-36.451 22.721ZM51.259 55.606l15.937.082c5.231-.817 8.746-3.678 8.746-8.091 0-5.558-4.169-8.582-11.606-8.582-6.375 0-11.197 1.062-12.995 2.452-.082 4.659-.082 9.48-.082 14.14Zm13.159 23.457c7.437 0 11.932-3.351 11.932-9.072 0-4.659-3.678-7.438-9.154-7.601l-15.937-.082c0 4.74 0 9.48.082 14.14 1.716 1.47 6.62 2.615 13.077 2.615Zm116.861-42.909c.654 19.86.654 38.74 0 58.192-7.519 1.226-15.528 1.226-23.047 0l-2.289-13.812h-1.471c-2.942 12.014-9.317 15.774-19.207 15.774-20.023 0-23.701-16.346-23.701-36.452 0-5.067.163-12.014.163-23.702a90.967 90.967 0 0 1 26.644 0V65.25c0 8.337 4.25 11.442 9.317 11.442 3.596 0 7.356-1.798 9.236-4.822V36.154a76.09 76.09 0 0 1 24.355 0Zm10.109 58.192c-.654-19.86-.654-38.74 0-58.192 7.519-1.226 15.528-1.226 23.048 0l2.288 13.813h1.471c2.942-12.014 9.317-15.774 19.207-15.774 20.024 0 23.701 16.346 23.701 36.451 0 5.068-.163 12.015-.163 23.702a90.974 90.974 0 0 1-26.644 0V65.25c0-8.336-4.25-11.442-9.317-11.442-3.596 0-7.356 1.798-9.236 4.822v35.716a76.095 76.095 0 0 1-24.355 0Z"></path></svg></a><button type="button" aria-label="Close menu" class="inline-flex h-10 w-10 items-center justify-center border border-rule text-fg"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-5 w-5"><path d="M6 6l12 12"></path><path d="M18 6L6 18"></path></svg></button></div><nav class="flex flex-1 flex-col gap-1 overflow-y-auto px-gutter pb-10 pt-4" aria-label="Mobile"><a class="display flex items-center justify-between border-b border-line py-4 text-[1.75rem] font-semibold text-fg aria-[current=page]:text-accent-strong" style="transition-delay:0ms" href="/" data-link="" data-prefetch="true">Home<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-5 w-5 -rotate-0 text-fg-faint"><path d="M6 18L17 7"></path><path d="M9 6h9v9"></path></svg></a><a aria-current="page" class="display flex items-center justify-between border-b border-line py-4 text-[1.75rem] font-semibold text-fg aria-[current=page]:text-accent-strong" style="transition-delay:30ms" href="/docs" data-link="" data-prefetch="true">Docs<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-5 w-5 -rotate-0 text-fg-faint"><path d="M6 18L17 7"></path><path d="M9 6h9v9"></path></svg></a><a class="display flex items-center justify-between border-b border-line py-4 text-[1.75rem] font-semibold text-fg aria-[current=page]:text-accent-strong" style="transition-delay:60ms" href="/guides" data-link="" data-prefetch="true">Guides<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-5 w-5 -rotate-0 text-fg-faint"><path d="M6 18L17 7"></path><path d="M9 6h9v9"></path></svg></a><a class="display flex items-center justify-between border-b border-line py-4 text-[1.75rem] font-semibold text-fg aria-[current=page]:text-accent-strong" style="transition-delay:90ms" href="/reference" data-link="" data-prefetch="true">Reference<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-5 w-5 -rotate-0 text-fg-faint"><path d="M6 18L17 7"></path><path d="M9 6h9v9"></path></svg></a><a class="display flex items-center justify-between border-b border-line py-4 text-[1.75rem] font-semibold text-fg aria-[current=page]:text-accent-strong" style="transition-delay:120ms" href="/blog" data-link="" data-prefetch="true">Blog<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-5 w-5 -rotate-0 text-fg-faint"><path d="M6 18L17 7"></path><path d="M9 6h9v9"></path></svg></a><div class="mt-8 flex flex-col gap-3"><a class="group/btn cut relative inline-flex select-none items-center justify-center gap-2.5 whitespace-nowrap font-semibold [font-stretch:100%] tracking-[-0.005em] transition-none active:translate-y-
1px h-[52px] px-6 text-[16px] [--cut:11px] bg-accent text-white hover:bg-fg hover:text-canvas w-full" href="/get" data-link="" data-prefetch="true">Install Bun v<!-- -->1.4.2</a><div class="mt-4 flex items-center justify-between"><div class="flex items-center gap-2"><a aria-label="GitHub" class="inline-flex h-10 w-10 items-center justify-center rounded-full border border-line text-fg-muted hover:text-fg" href="https://github.com/oven-sh/bun" data-link="" data-prefetch="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-[18px] w-[18px]"><path d="M9.5 21v-3.5l1-1.5C7 15.5 5 14 5 10.5L6.5 8 6 4.5l3.5 1.5h5l3.5-1.5-.5 3.5 1.5 2.5c0 3.5-2 5-5.5 5.5l1 1.5V21"></path><path d="M9.5 18.5H7l-1.5-2L4 15.5"></path><rect x="8.5" y="9.75" width="1.75" height="2.25" fill="currentColor" stroke="none"></rect><rect x="13.75" y="9.75" width="1.75" height="2.25" fill="currentColor" stroke="none"></rect></svg></a><a aria-label="Discord" class="inline-flex h-10 w-10 items-center justify-center rounded-full border border-line text-fg-muted hover:text-fg" href="/discord" data-link="" data-prefetch="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-[18px] w-[18px]"><path d="M8 4.5l1 2h6l1-2 4 1.5 1.5 7-1.5 5-3.5 1.5-1.5-2h-6l-1.5 2L4 18l-1.5-5L4 6z"></path><path d="M8.5 16.5c1 .5 2.25.75 3.5.75s2.5-.25 3.5-.75"></path><rect x="7.5" y="10" width="2.5" height="3.25" fill="currentColor" stroke="none"></rect><rect x="14" y="10" width="2.5" height="3.25" fill="currentColor" stroke="none"></rect></svg></a><a aria-label="X (Twitter)" class="inline-flex h-10 w-10 items-center justify-center rounded-full border border-line text-fg-muted hover:text-fg" href="https://x.com/bunjavascript" data-link="" data-prefetch="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-[18px] w-[18px]"><path d="M3.5 3.75h4.75l12.25 15v1.5h-4.75z" fill="currentColor" opacity="0.3" stroke="none"></path><path d="M3.5 3.75h4.75l12.25 15v1.5h-4.75z"></path><path d="M19.75 3.75l-6.1 6.95M4.25 20.25l6.1-6.95"></path></svg></a></div></div></div></nav></div><main id="main" data-pagefind-body="true" class="flex-1"><nav aria-label="Documentation sections" data-pagefind-ignore="true" class="border-b border-line bg-canvas"><div class="mx-auto -mb-px flex w-full max-w-[100rem] gap-1 overflow-x-auto overflow-y-hidden px-gutter scroll-none"><a aria-current="page" class="inline-flex h-11 shrink-0 items-center gap-1.5 whitespace-nowrap border-b-2 px-2.5 text-[14px] font-medium transition-colors border-accent text-fg" href="/docs" data-link="" data-prefetch="hover"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 opacity-80"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><polygon points="10.5,6 10.5,3 13.5,3 13.5,6 14.5,6 15,6.5 17,4.5 19.5,7 17.5,9 18,9.5 18,10.5 21,10.5 21,13.5 18,13.5 18,14.5 17.5,15 19.5,17 17,19.5 15,17.5 14.5,18 13.5,18 13.5,21 10.5,21 10.5,18 9.5,18 9,17.5 7,19.5 4.5,17 6.5,15 6,14.5 6,13.5 3,13.5 3,10.5 6,10.5 6,9.5 6.5,9 4.5,7 7,4.5 9,6.5 9.5,6"/><rect x="9.5" y="9.5" width="5" height="5"/></svg></span>Runtime</a><a class="inline-flex h-11 shrink-0 items-center gap-1.5 whitespace-nowrap border-b-2 px-2.5 text-[14px] font-medium transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/pm/cli/install" data-link="" data-prefetch="hover"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 opacity-80"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M12 2.5l9 4.5v10l-9 4.5-9-4.5V7z"/><path d="M4 7.5l8 4 8-4M12 11.5V21"/><path d="M12 2.5l9 4.5-9 4.5L3 7z" fill="currentColor" opacity="0.3" stroke="none"/></svg></span>Package Manager</a><a class="inline-flex h-11 shrink-0 items-center gap-1.5 whitespace-nowrap border-b-2 px-2.5 text-[14px] font-medium transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/bundler" data-link="" data-prefetch="hover"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 opacity-80"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M9 3h8l4 4v10H9z" fill="currentColor" opacity="0.3" stroke="none"/><path d="M9 3h8l4 4v10H9z"/><path d="M6 6.5V20h11"/><path d="M3 8v13h11"/></svg></span>Bundler</a><a class="inline-flex h-11 shrink-0 items-center gap-1.5 whitespace-nowrap border-b-2 px-2.5 text-[14px] font-medium transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/test" data-link="" data-prefetch="hover"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 opacity-80"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M8.5 3h7"/><path d="M10 3v5L4 20h16L14 8V3"/><path d="M7 14h10l3 6H4z" fill="currentColor" opacity="0.3" stroke="none"/><path d="M7.5 14h9"/></svg></span>Test Runner</a><a class="inline-flex h-11 shrink-0 items-center gap-1.5 whitespace-nowrap border-b-2 px-2.5 text-[14px] font-medium transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/guides" data-link="" data-prefetch="hover"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 opacity-80"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M9 3.5l6 3V21l-6-3z" fill="currentColor" opacity="0.3" stroke="none"/><path d="M3 6.5l6-3 6 3 6-3V18l-6 3-6-3-6 3z"/><path d="M9 4.5V18M15 6.5V20"/></svg></span>Guides</a><a class="inline-flex h-11 shrink-0 items-center gap-1.5 whitespace-nowrap border-b-2 px-2.5 text-[14px] font-medium transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/reference" data-link="" data-prefetch="hover"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 opacity-80"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M6 3h11l3 3v10.5H4V5z" fill="currentColor" opacity="0.3" stroke="none"/><path d="M4 5l2-2h11l3 3v15H6l-2-2z"/><path d="M20 16.5H6l-2 2"/><path d="M8 3v13.5"/></svg></span>Reference</a><a class="inline-flex h-11 shrink-0 items-center gap-1.5 whitespace-nowrap border-b-2 px-2.5 text-[14px] font-medium transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/blog" data-link="" data-prefetch="hover"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 opacity-80"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M3 10h4V4h10l4 4v12H5l-2-2z"/><path d="M7 10v10"/><path d="M10.5 7H17v3.5h-6.5z" fill="currentColor" opacity="0.3" stroke="none"/><path d="M10.5 7H17v3.5h-6.5z"/><path d="M10.5 14H18M10.5 17H15"/></svg></span>Blog</a><a class="inline-flex h-11 shrink-0 items-center gap-1.5 whitespace-nowrap border-b-2 px-2.5 text-[14px] font-medium transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/feedback" data-link="" data-prefetch="hover"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 opacity-80"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M8.5 3h7L19 6.5v5L15.5 15v3h-7v-3L5 11.5v-5z"/><path d="M10 9.5l2 2 2-2M12 11.5V18"/><path d="M9.5 21h5"/></svg></span>Feedback</a></div></nav><div class="mx-auto flex w-full max-w-[100rem]"><button type="button" aria-expanded="false" aria-controls="docs-sidebar-rail" class="mono fixed bottom-4 left-4 z-30 inline-flex items-center gap-2 rounded-full border border-line bg-surface px-4 py-2 text-[12px] uppercase tracking-[0.12em] text-fg shadow-sm md:hidden"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-3.5 w-3.5"><path d="M4 6h16"></path><path d="M4 12h16"></path><path d="M4 18h16"></path></svg>Browse <!-- -->docs</button><aside data-pagefind-ignore="true" id="docs-sidebar-rail" class="fixed inset-y-0 left-0 z-50 w-[min(20rem,85vw)] -translate-x-full overflow-y-auto border-r border-line bg-canvas transition-transform duration-300 scroll-thin md:sticky md:top-header md:z-0 md:h-[calc(100vh-var(--header-h))] md:w-64 md:shrink-0 md:translate-x-0 md:bg-transparent md:transition-none lg:w-72"><div class="flex items-center justify-between border-b border-line px-5 py-3 md:hidden"><span class="label">Runtime</span><button type="button" aria-label="Close" class="inline-flex h-9 w-9 items-center justify-center rounded-full border border-line"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-4 w-4"><path d="M6 6l12 12"></path><path d="M18 6L6 18"></path></svg></button></div><nav id="docs-sidebar" aria-label="Runtime navigation" class="px-5 py-6 md:pl-gutter md:pr-4"><ul class="flex flex-col gap-7"><li><p class="mb-2 flex items-center gap-2 text-[13px] font-semibold text-fg"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 text-fg-faint"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M3 4h14l4 4v12H3z"/><path d="M7 10l3 3-3 3"/><path d="M12.5 16H17"/></svg></span>Get Started</p><ul class="border-l border-line"><li><a aria-current="page" class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-accent font-semibold text-fg" href="/docs" data-link="" data-prefetch="hover">Welcome to Bun</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/installation" data-link="" data-prefetch="hover">Installation</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/quickstart" data-link="" data-prefetch="hover">Quickstart</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/typescript" data-link="" data-prefetch="hover">TypeScript</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/typescript-6" data-link="" data-prefetch="hover">TypeScript 6 and 7</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/templating/init" data-link="" data-prefetch="hover">bun init</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/templating/create" data-link="" data-prefetch="hover">bun create</a></li></ul></li><li><p class="mb-2 flex items-center gap-2 text-[13px] font-semibold text-fg"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 text-fg-faint"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><polygon points="10.5,6 10.5,3 13.5,3 13.5,6 14.5,6 15,6.5 17,4.5 19.5,7 17.5,9 18,9.5 18,10.5 21,10.5 21,13.5 18,13.5 18,14.5 17.5,15 19.5,17 17,19.5 15,17.5 14.5,18 13.5,18 13.5,21 10.5,21 10.5,18 9.5,18 9,17.5 7,19.5 4.5,17 6.5,15 6,14.5 6,13.5 3,13.5 3,10.5 6,10.5 6,9.5 6.5,9 4.5,7 7,4.5 9,6.5 9.5,6"/><rect x="9.5" y="9.5" width="5" height="5"/></svg></span>
1Core Runtime</p><ul class="border-l border-line"><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime" data-link="" data-prefetch="hover">Bun Runtime</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/watch-mode" data-link="" data-prefetch="hover">Watch Mode</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/debugger" data-link="" data-prefetch="hover">Debugging</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/repl" data-link="" data-prefetch="hover">REPL</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/bunfig" data-link="" data-prefetch="hover">bunfig.toml</a></li></ul></li><li><p class="mb-2 flex items-center gap-2 text-[13px] font-semibold text-fg"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 text-fg-faint"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M5 3h9l5 5v13H5z"/><path d="M14 3v5h5"/></svg></span>File &amp; Module System</p><ul class="border-l border-line"><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/file-types" data-link="" data-prefetch="hover">File Types</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/module-resolution" data-link="" data-prefetch="hover">Module Resolution</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/jsx" data-link="" data-prefetch="hover">JSX</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/auto-install" data-link="" data-prefetch="hover">Auto-install</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/plugins" data-link="" data-prefetch="hover">Plugins</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/file-system-router" data-link="" data-prefetch="hover">File System Router</a></li></ul></li><li><p class="mb-2 flex items-center gap-2 text-[13px] font-semibold text-fg"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 text-fg-faint"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M3 3h15l3 3v4H3z"/><rect x="3" y="14" width="18" height="7"/><rect x="6" y="5.5" width="2" height="2" fill="currentColor" stroke="none"/><rect x="6" y="16.5" width="2" height="2" fill="currentColor" stroke="none"/><path d="M13 6.5h4M13 17.5h4"/></svg></span>HTTP server</p><ul class="border-l border-line"><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/http/server" data-link="" data-prefetch="hover">Server</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/http/routing" data-link="" data-prefetch="hover">Routing</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/http/cookies" data-link="" data-prefetch="hover">Cookies</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/http/tls" data-link="" data-prefetch="hover">TLS</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/http/error-handling" data-link="" data-prefetch="hover">Error Handling</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/http/metrics" data-link="" data-prefetch="hover">Metrics</a></li></ul></li><li><p class="mb-2 flex items-center gap-2 text-[13px] font-semibold text-fg"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 text-fg-faint"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M8 3h8l5 5v8l-5 5H8l-5-5V8z"/><path d="M3 12h18"/><path d="M10 3.5L8 8v8l2 4.5M14 3.5l2 4.5v8l-2 4.5"/></svg></span>Networking</p><ul class="border-l border-line"><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/networking/fetch" data-link="" data-prefetch="hover">Fetch</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/http/websockets" data-link="" data-prefetch="hover">WebSockets</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/networking/tcp" data-link="" data-prefetch="hover">TCP</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/networking/udp" data-link="" data-prefetch="hover">UDP</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/networking/dns" data-link="" data-prefetch="hover">DNS</a></li></ul></li><li><p class="mb-2 flex items-center gap-2 text-[13px] font-semibold text-fg"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 text-fg-faint"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M4 5.5l2-2h12l2 2-2 2H6z" fill="currentColor" opacity="0.3" stroke="none"/><path d="M6 3.5h12l2 2v13l-2 2H6l-2-2v-13z"/><path d="M4.5 6L6 7.5h12L19.5 6"/><path d="M4.5 12.5L6 14h12l1.5-1.5"/></svg></span>Data &amp; Storage</p><ul class="border-l border-line"><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/cookies" data-link="" data-prefetch="hover">Cookies</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/file-io" data-link="" data-prefetch="hover">File I/O</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/streams" data-link="" data-prefetch="hover">
1Streams</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/binary-data" data-link="" data-prefetch="hover">Binary Data</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/archive" data-link="" data-prefetch="hover">Archive</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/sql" data-link="" data-prefetch="hover">SQL</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/sqlite" data-link="" data-prefetch="hover">SQLite</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/s3" data-link="" data-prefetch="hover">S3</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/redis" data-link="" data-prefetch="hover">Redis</a></li></ul></li><li><p class="mb-2 flex items-center gap-2 text-[13px] font-semibold text-fg"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 text-fg-faint"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M12 21v-9L4.5 4.5"/><path d="M12 12l7.5-7.5"/><path d="M4 10V4h6"/><path d="M20 10V4h-6"/></svg></span>Concurrency</p><ul class="border-l border-line"><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/workers" data-link="" data-prefetch="hover">Workers</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/module-graph" data-link="" data-prefetch="hover">ModuleGraph</a></li></ul></li><li><p class="mb-2 flex items-center gap-2 text-[13px] font-semibold text-fg"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 text-fg-faint"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M4.5 4.5h12l3 3v8h-15z"/><path d="M2.5 20h19L20 15.5H4z" fill="currentColor" opacity="0.3" stroke="none"/><path d="M2.5 20h19L20 15.5H4z"/></svg></span>Process &amp; System</p><ul class="border-l border-line"><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/environment-variables" data-link="" data-prefetch="hover">Environment Variables</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/shell" data-link="" data-prefetch="hover">Shell</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/child-process" data-link="" data-prefetch="hover">Spawn</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/webview" data-link="" data-prefetch="hover">WebView</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/cron" data-link="" data-prefetch="hover">Cron</a></li></ul></li><li><p class="mb-2 flex items-center gap-2 text-[13px] font-semibold text-fg"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 text-fg-faint"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M3 7h4.5V3h5v4H17v4.5h4v5h-4V21h-5v-4H8v4H3z"/></svg></span>Interop &amp; Tooling</p><ul class="border-l border-line"><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/node-api" data-link="" data-prefetch="hover">Node-API</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/ffi" data-link="" data-prefetch="hover">FFI</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/c-compiler" data-link="" data-prefetch="hover">C Compiler</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/transpiler" data-link="" data-prefetch="hover">Transpiler</a></li></ul></li><li><p class="mb-2 flex items-center gap-2 text-[13px] font-semibold text-fg"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 text-fg-faint"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M18 3l-3 3 3 3 3-3v4.5l-3 3h-4.5L6 21l-3-3 7.5-7.5V6l3-3z"/></svg></span>Utilities</p><ul class="border-l border-line"><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/csrf" data-link="" data-prefetch="hover">CSRF Protection</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/secrets" data-link="" data-prefetch="hover">Secrets</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/console" data-link="" data-prefetch="hover">Console</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/toml" data-link="" data-prefetch="hover">TOML</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/yaml" data-link="" data-prefetch="hover">YAML</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/markdown" data-link="" data-prefetch="hover">Markdown</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/json5" data-link="" data-prefetch="hover">JSON5</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/xml" data-link="" data-prefetch="hover">XML</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/jsonl" data-link="" data-prefetch="hover">JSONL</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/html-rewriter" data-link="" data-prefetch="hover">HTMLRewriter</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/image" data-link="" data-prefetch="hover">Image</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/hashing" data-link="" data-prefetch="hover">Hashing</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/glob" data-link="" data-prefetch="hover">Glob</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/semver" data-link="" data-prefetch="hover">Semver</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/color" data-link="" data-prefetch="hover">Color</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/utils" data-link="" data-prefetch="hover">Utils</a></li></ul></li><li><p class="mb-2 flex items-center gap-2 text-[13px] font-semibold text-fg"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 text-fg-faint"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M8 3h8l5 5v8l-5 5H8l-5-5V8z"/><path d="M7.5 12l3 3 6-6"/></svg></span>Standards &amp; Compatibility</p><ul class="border-l border-line"><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/globals" data-link="" data-prefetch="hover">Globals</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/bun-apis" data-link="" data-prefetch="hover">Bun APIs</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/web-apis" data-link="" data-prefetch="hover">Web APIs</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/runtime/nodejs-compat" data-link="" data-prefetch="hover">Node.js Compatibility</a></li></ul></li><li><p class="mb-2 flex items-center gap-2 text-[13px] font-semibold text-fg"><span aria-hidden="true" class="inline-flex shrink-0 items-center justify-center [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 text-fg-faint"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M12 20.5L3 11.5V7l3.5-3.5H9l3 3 3-3h2.5L21 7v4.5z"/></svg></span>Contributing</p><ul class="border-l border-line"><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/project/roadmap" data-link="" data-prefetch="hover">Roadmap</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/project/benchmarking" data-link="" data-prefetch="hover">Benchmarking</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/project/contributing" data-link="" data-prefetch="hover">Contributing</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/project/building-windows" data-link="" data-prefetch="hover">Building Windows</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/project/bindgen" data-link="" data-prefetch="hover">Bindgen</a></li><li><a class="-ml-px block border-l py-[5px] pl-4 pr-2 text-[14px] leading-snug transition-colors border-transparent text-fg-muted hover:border-line-strong hover:text-fg" href="/docs/project/lice
1nse" data-link="" data-prefetch="hover">License</a></li></ul></li></ul></nav>
1<script>try{var r=document.currentScript.parentElement,k="rail:docs",v=sessionStorage.getItem(k);if(v)r.scrollTop=+v;r.addEventListener("scroll",function(){sessionStorage.setItem(k,r.scrollTop)},{passive:true})}catch(e){}</script>
1</aside><div class="min-w-0 flex-auto px-gutter py-10 md:px-10 lg:px-14"><div class="grid gap-12"><article id="docs-content" class="min-w-0 max-w-3xl mx-auto w-full"><header class="mb-8"><div class="flex items-start justify-between gap-4"><nav aria-label="Breadcrumb" class="mb-3"><ol class="flex flex-wrap items-center gap-x-1.5 gap-y-1 text-[13px] font-medium text-fg-faint"><li class="flex items-center gap-1.5"><a class="text-fg-muted transition-colors hover:text-fg" href="/docs" data-link="" data-prefetch="true">Runtime</a></li><li class="flex items-center gap-1.5"><span aria-hidden="true" class="text-fg-faint/70">›</span><span class="text-accent-strong">Get Started</span></li></ol></nav><div class="relative inline-flex text-[13px] -mt-1 hidden shrink-0 sm:inline-flex"><button type="button" class="relative inline-flex h-8 items-center gap-2 border border-line px-2.5 text-fg-muted transition-colors hover:z-10 hover:border-rule hover:text-fg"><span class="t-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M5.5 16H3V3h13v2.5"/><path d="M8 8h9l4 4v9H8z"/></svg></span>Copy page</button><button type="button" aria-label="More page actions" aria-haspopup="menu" aria-expanded="false" class="-ml-px inline-flex h-8 w-8 items-center justify-center border border-line text-fg-muted transition-colors hover:z-10 hover:border-rule hover:text-fg"><span class="t-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 transition-transform" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M6 9l6 6 6-6"/></svg></span></button></div></div><h1 class="display text-balance text-[clamp(1.9rem,4vw,2.6rem)] font-bold leading-[1.08] tracking-tight text-fg">Welcome to Bun</h1><p class="mt-3 max-w-[64ch] text-pretty text-[1.05rem] leading-relaxed text-fg-muted">Bun is an all-in-one toolkit for developing modern JavaScript/TypeScript applications.</p></header><div class="DocSearch-content docs-prose prose w-full max-w-none" style="--tw-prose-body:rgb(var(--c-fg) / 0.88);--tw-prose-headings:rgb(var(--c-fg));--tw-prose-lead:rgb(var(--c-fg-muted));--tw-prose-links:rgb(var(--c-fg));--tw-prose-bold:rgb(var(--c-fg));--tw-prose-counters:rgb(var(--c-fg-faint));--tw-prose-bullets:rgb(var(--c-line-strong));--tw-prose-hr:rgb(var(--c-line));--tw-prose-quotes:rgb(var(--c-fg));--tw-prose-quote-borders:rgb(var(--c-line-strong));--tw-prose-captions:rgb(var(--c-fg-faint));--tw-prose-kbd:rgb(var(--c-fg));--tw-prose-kbd-shadows:var(--c-fg);--tw-prose-code:rgb(var(--c-fg));--tw-prose-pre-code:rgb(var(--c-code-fg));--tw-prose-pre-bg:rgb(var(--c-code-bg));--tw-prose-th-borders:rgb(var(--c-line-strong));--tw-prose-td-borders:rgb(var(--c-line))"><div class="card-group not-prose my-6 grid gap-4 grid-cols-1 sm:grid-cols-2 [&amp;&gt;.doc-card-wrap]:my-0 [&amp;&gt;.doc-card-wrap]:h-full"><div class="doc-card-wrap not-prose my-4"><a href="/docs/runtime" class="doc-card card group/card relative flex h-full flex-col overflow-hidden rounded-xl border border-line bg-surface text-left font-normal text-fg no-underline transition-colors hover:border-accent/70 focus-visible:border-accent"><div class="relative flex h-full px-5 py-4 flex-col gap-2.5"><span class="doc-card-icon inline-flex shrink-0 text-accent"><span class="doc-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-[22px] w-[22px]" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><polygon points="10.5,6 10.5,3 13.5,3 13.5,6 14.5,6 15,6.5 17,4.5 19.5,7 17.5,9 18,9.5 18,10.5 21,10.5 21,13.5 18,13.5 18,14.5 17.5,15 19.5,17 17,19.5 15,17.5 14.5,18 13.5,18 13.5,21 10.5,21 10.5,18 9.5,18 9,17.5 7,19.5 4.5,17 6.5,15 6,14.5 6,13.5 3,13.5 3,10.5 6,10.5 6,9.5 6.5,9 4.5,7 7,4.5 9,6.5 9.5,6"/><rect x="9.5" y="9.5" width="5" height="5"/></svg></span></span><div class="flex min-w-0 flex-1 flex-col"><p class="doc-card-title m-0 text-[15px] font-semibold leading-snug text-fg">
1Bun Runtime</p><div class="doc-card-body text-[14px] leading-relaxed text-fg-muted mt-1 [&amp;_p]:my-0 [&amp;_p+p]:mt-2 [&amp;_strong]:font-semibold [&amp;_strong]:text-fg [&amp;_ul]:my-1 [&amp;_ul]:list-disc [&amp;_ul]:pl-5 [&amp;_code]:rounded [&amp;_code]:border [&amp;_code]:border-line [&amp;_code]:bg-code-bg [&amp;_code]:px-[0.3em] [&amp;_code]:py-[0.05em] [&amp;_code]:font-mono [&amp;_code]:text-[0.86em] [&amp;_code]:text-fg"><p>A fast JavaScript runtime designed as a drop-in replacement for Node.js</p></div><div class="mt-auto pt-4"><span class="inline-flex items-center gap-1.5 text-[13.5px] font-medium text-fg-muted transition-colors group-hover/card:text-accent-strong [&amp;_code]:font-mono [&amp;_code]:text-[0.92em]"><span>Get started with <code>bun run</code></span><span class="doc-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 transition-transform duration-150 group-hover/card:translate-x-0.5" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M4 12h14"/><path d="M13 6l6 6-6 6"/></svg></span></span></div></div></div></a></div><div class="doc-card-wrap not-prose my-4"><a href="/docs/pm/cli/install" class="doc-card card group/card relative flex h-full flex-col overflow-hidden rounded-xl border border-line bg-surface text-left font-normal text-fg no-underline transition-colors hover:border-accent/70 focus-visible:border-accent"><div class="relative flex h-full px-5 py-4 flex-col gap-2.5"><span class="doc-card-icon inline-flex shrink-0 text-accent"><span class="doc-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-[22px] w-[22px]" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M12 2.5l9 4.5v10l-9 4.5-9-4.5V7z"/><path d="M4 7.5l8 4 8-4M12 11.5V21"/><path d="M12 2.5l9 4.5-9 4.5L3 7z" fill="currentColor" opacity="0.3" stroke="none"/></svg></span></span><div class="flex min-w-0 flex-1 flex-col"><p class="doc-card-title m-0 text-[15px] font-semibold leading-snug text-fg">Bun Package Manager</p><div class="doc-card-body text-[14px] leading-relaxed text-fg-muted mt-1 [&amp;_p]:my-0 [&amp;_p+p]:mt-2 [&amp;_strong]:font-semibold [&amp;_strong]:text-fg [&amp;_ul]:my-1 [&amp;_ul]:list-disc [&amp;_ul]:pl-5 [&amp;_code]:rounded [&amp;_code]:border [&amp;_code]:border-line [&amp;_code]:bg-code-bg [&amp;_code]:px-[0.3em] [&amp;_code]:py-[0.05em] [&amp;_code]:font-mono [&amp;_code]:text-[0.86em] [&amp;_code]:text-fg"><p>Install packages up to 30x faster than npm with a global cache and workspaces</p></div><div class="mt-auto pt-4"><span class="inline-flex items-center gap-1.5 text-[13.5px] font-medium text-fg-muted transition-colors group-hover/card:text-accent-strong [&amp;_code]:font-mono [&amp;_code]:text-[0.92em]"><span>Get started with <code>bun install</code></span><span class="doc-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 transition-transform duration-150 group-hover/card:translate-x-0.5" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M4 12h14"/><path d="M13 6l6 6-6 6"/></svg></span></span></div></div></div></a></div><div class="doc-card-wrap not-prose my-4"><a href="/docs/test" class="doc-card card group/card relative flex h-full flex-col overflow-hidden rounded-xl border border-line bg-surface text-left font-normal text-fg no-underline transition-colors hover:border-accent/70 focus-visible:border-accent"><div class="relative flex h-full px-5 py-4 flex-col gap-2.5"><span class="doc-card-icon inline-flex shrink-0 text-accent"><span class="doc-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-[22px] w-[22px]" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M8.5 3h7"/><path d="M10 3v5L4 20h16L14 8V3"/><path d="M7 14h10l3 6H4z" fill="currentColor" opacity="0.3" stroke="none"/><path d="M7.5 14h9"/></svg></span></span><div class="flex min-w-0 flex-1 flex-col"><p class="doc-card-title m-0 text-[15px] font-semibold leading-snug text-fg">Bun Test Runner</p><div class="doc-card-body text-[14px] leading-relaxed text-fg-muted mt-1 [&amp;_p]:my-0 [&amp;_p+p]:mt-2 [&amp;_strong]:font-semibold [&amp;_strong]:text-fg [&amp;_ul]:my-1 [&amp;_ul]:list-disc [&amp;_ul]:pl-5 [&amp;_code]:rounded [&amp;_code]:border [&amp;_code]:border-line [&amp;_code]:bg-code-bg [&amp;_code]:px-[0.3em] [&amp;_code]:py-[0.05em] [&amp;_code]:font-mono [&amp;_code]:text-[0.86em] [&amp;_code]:text-fg"><p>Jest-compatible, TypeScript-first tests with snapshots, DOM, and watch mode</p></div><div class="mt-auto pt-4"><span class="inline-flex items-center gap-1.5 text-[13.5px] font-medium text-fg-muted transition-colors group-hover/card:text-accent-strong [&amp;_code]:font-mono [&amp;_code]:text-[0.92em]"><span>Get started with <code>bun test</code></span><span class="doc-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 transition-transform duration-150 group-hover/card:translate-x-0.5" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M4 12h14"/><path d="M13 6l6 6-6 6"/></svg></span></span></div></div></div></a></div><div class="doc-card-wrap not-prose my-4"><a href="/docs/bundler" class="doc-card card group/card relative flex h-full flex-col overflow-hidden rounded-xl border border-line bg-surface text-left font-normal text-fg no-underline transition-colors hover:border-accent/70 focus-visible:border-accent"><div class="relative flex h-full px-5 py-4 flex-col gap-2.5">
1<span class="doc-card-icon inline-flex shrink-0 text-accent"><span class="doc-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-[22px] w-[22px]" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M9 3h8l4 4v10H9z" fill="currentColor" opacity="0.3" stroke="none"/><path d="M9 3h8l4 4v10H9z"/><path d="M6 6.5V20h11"/><path d="M3 8v13h11"/></svg></span></span><div class="flex min-w-0 flex-1 flex-col"><p class="doc-card-title m-0 text-[15px] font-semibold leading-snug text-fg">Bun Bundler</p><div class="doc-card-body text-[14px] leading-relaxed text-fg-muted mt-1 [&amp;_p]:my-0 [&amp;_p+p]:mt-2 [&amp;_strong]:font-semibold [&amp;_strong]:text-fg [&amp;_ul]:my-1 [&amp;_ul]:list-disc [&amp;_ul]:pl-5 [&amp;_code]:rounded [&amp;_code]:border [&amp;_code]:border-line [&amp;_code]:bg-code-bg [&amp;_code]:px-[0.3em] [&amp;_code]:py-[0.05em] [&amp;_code]:font-mono [&amp;_code]:text-[0.86em] [&amp;_code]:text-fg"><p>Bundle TypeScript, JSX, React &amp; CSS for both browsers and servers</p></div><div class="mt-auto pt-4"><span class="inline-flex items-center gap-1.5 text-[13.5px] font-medium text-fg-muted transition-colors group-hover/card:text-accent-strong [&amp;_code]:font-mono [&amp;_code]:text-[0.92em]"><span>Get started with <code>bun build</code></span><span class="doc-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-3.5 w-3.5 transition-transform duration-150 group-hover/card:translate-x-0.5" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M4 12h14"/><path d="M13 6l6 6-6 6"/></svg></span></span></div></div></div></a></div></div><hr/><h2 id="get-started" class="anchored">Get Started<a href="#get-started" aria-label="Permalink" data-pagefind-ignore="" class="anchor">#</a></h2><p>Bun ships as a single, dependency-free binary and includes a runtime, package manager, test runner, and bundler. New to Bun?</p><div class="card-group not-prose my-6 grid gap-4 grid-cols-1 sm:grid-cols-2 [&amp;&gt;.doc-card-wrap]:my-0 [&amp;&gt;.doc-card-wrap]:h-full"><div class="doc-card-wrap not-prose my-4"><a href="/docs/installation" class="doc-card card group/card relative flex h-full flex-col overflow-hidden rounded-xl border border-line bg-surface text-left font-normal text-fg no-underline transition-colors hover:border-accent/70 focus-visible:border-accent"><div class="relative flex h-full px-5 py-4 flex-col gap-2.5"><span class="doc-card-icon inline-flex shrink-0 text-accent"><span class="doc-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-[22px] w-[22px]" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M12 3v11"/><path d="M6.5 9.5L12 15l5.5-5.5"/><path d="M3 14v6h18v-6"/></svg></span></span><div class="flex min-w-0 flex-1 flex-col"><p class="doc-card-title m-0 text-[15px] font-semibold leading-snug text-fg">Install Bun</p><div class="doc-card-body text-[14px] leading-relaxed text-fg-muted mt-1 [&amp;_p]:my-0 [&amp;_p+p]:mt-2 [&amp;_strong]:font-semibold [&amp;_strong]:text-fg [&amp;_ul]:my-1 [&amp;_ul]:list-disc [&amp;_ul]:pl-5 [&amp;_code]:rounded [&amp;_code]:border [&amp;_code]:border-line [&amp;_code]:bg-code-bg [&amp;_code]:px-[0.3em] [&amp;_code]:py-[0.05em] [&amp;_code]:font-mono [&amp;_code]:text-[0.86em] [&amp;_code]:text-fg"><p>Supported platforms and all install methods.</p></div></div></div></a></div><div class="doc-card-wrap not-prose my-4"><a href="/docs/quickstart" class="doc-card card group/card relative flex h-full flex-col overflow-hidden rounded-xl border border-line bg-surface text-left font-normal text-fg no-underline transition-colors hover:border-accent/70 focus-visible:border-accent"><div class="relative flex h-full px-5 py-4 flex-col gap-2.5">
1<span class="doc-card-icon inline-flex shrink-0 text-accent"><span class="doc-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-[22px] w-[22px]" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M13 3L5 13h6l-1 8 9-10h-6z"/></svg></span></span><div class="flex min-w-0 flex-1 flex-col"><p class="doc-card-title m-0 text-[15px] font-semibold leading-snug text-fg">Quickstart</p><div class="doc-card-body text-[14px] leading-relaxed text-fg-muted mt-1 [&amp;_p]:my-0 [&amp;_p+p]:mt-2 [&amp;_strong]:font-semibold [&amp;_strong]:text-fg [&amp;_ul]:my-1 [&amp;_ul]:list-disc [&amp;_ul]:pl-5 [&amp;_code]:rounded [&amp;_code]:border [&amp;_code]:border-line [&amp;_code]:bg-code-bg [&amp;_code]:px-[0.3em] [&amp;_code]:py-[0.05em] [&amp;_code]:font-mono [&amp;_code]:text-[0.86em] [&amp;_code]:text-fg"><p>Hello world in minutes with Bun.serve.</p></div></div></div></a></div></div><hr/><h2 id="what-s-inside" class="anchored">What&#x27;s Inside<a href="#what-s-inside" aria-label="Permalink" data-pagefind-ignore="" id="whats-inside" class="anchor">#</a></h2><ul><li>Runtime: Execute JavaScript/TypeScript files and package scripts with near-zero overhead.</li><li>Package Manager: Fast installs, workspaces, overrides, and audits with <code>bun install</code>.</li><li>Test Runner: Jest-compatible, TypeScript-first tests with snapshots, DOM, and watch mode.</li><li>Bundler: Native bundling for JS/TS/JSX with splitting, plugins, and HTML imports.</li></ul><p>Explore each area using the cards above. Each section is structured with an overview, short examples, reference, and best practices for fast scanning and deep dives.</p><hr/><h2 id="what-is-bun" class="anchored">What is Bun?<a href="#what-is-bun" aria-label="Permalink" data-pagefind-ignore="" class="anchor">#</a></h2><p>Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called <code>bun</code>.</p><p>At its core is the <em>Bun runtime</em>, a fast JavaScript runtime designed as <strong>a drop-in replacement for Node.js</strong>. It&#x27;s written in Rust and powered by JavaScriptCore, reducing startup time and memory usage.</p><div class="DocFence group/fence relative my-5 overflow-hidden rounded-lg border border-line bg-code-bg text-code-fg [&amp;:has(+.DocFence-output)]:rounded-b-none" data-lang="bash"><div class="DocFenceHeader flex min-h-[34px] items-center gap-2 border-b border-line bg-subtle/70 px-3.5 py-1.5 font-mono text-[12px] leading-none text-fg-muted"><span class="doc-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-4 w-4 shrink-0" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M3 4h14l4 4v12H3z"/><path d="M7 10l3 3-3 3"/><path d="M12.5 16H17"/></svg></span><span class="truncate" translate="no">terminal</span></div><div class="relative" style="--doc-prompt:&quot;$ &quot;"><div class="CodeBlock group/code !my-0 !rounded-none !border-0 [&amp;_pre]:!overflow-x-visible [&amp;_.line-hl]:inline-block [&amp;_.line-hl]:min-w-[calc(100%+4.1rem)] [&amp;_.line-hl]:-ml-[1.1rem] [&amp;_.line-hl]:pl-[calc(1.1rem-3px)] [&amp;_.line-hl]:pr-12 [&amp;_.line-hl]:align-top [&amp;_.line-hl]:h-5 [&amp;_.line-hl]:border-l-[3px] [&amp;_.line-hl]:border-accent [&amp;_.line-hl]:bg-accent/[0.09] [&amp;_.line:not(:empty):has(span)]:before:content-[var(--doc-prompt)] [&amp;_.line]:before:select-none [&amp;_.line]:before:text-fg-faint [&amp;_.line:has(&gt;.s-6272a4:first-child)]:before:content-none"><div class="relative"><div class="CodeBlockScroll"><div data-h="0"><pre class="shiki"><code><span class="line"><span class="s-f8f8f2">bun run index.tsx  </span><span class="s-6272a4"># TS and JSX supported by default</span></span></code></pre></div></div><button type="button" aria-label="Copy to clipboard" class="CopyIcon group/copy inline-flex items-center justify-center rounded-md text-fg-faint transition-[color,background,opacity] hover:bg-fg/[0.06] hover:text-fg h-7 w-7 copy absolute right-1.5 top-[-3px]"><span class="relative block h-4 w-4"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="absolute inset-0 h-4 w-4 transition-[opacity,transform] duration-200 opacity-100"><path d="M5.5 16H3V3h13v2.5"></path><path d="M8 8h9l4 4v9H8z"></path></svg><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="absolute inset-0 h-4 w-4 text-success transition-[opacity,transform] duration-200 scale-75 opacity-0"><path d="M4 12l5 5L20 6"></path></svg></span></button></div></div></div></div><p>The <code>bun</code> command-line tool also implements a test runner, script runner, and Node.js-compatible package manager. All three are significantly faster than existing tools, and you can use them in existing Node.js projects with little to no changes.</p><div class="DocFence group/fence relative my-5 overflow-hidden rounded-lg border border-line bg-code-bg text-code-fg [&amp;:has(+.DocFence-output)]:rounded-b-none" data-lang="bash"><div class="DocFenceHeader flex min-h-[34px] items-center gap-2 border-b border-line bg-subtle/70 px-3.5 py-1.5 font-mono text-[12px] leading-none text-fg-muted"><span class="doc-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-4 w-4 shrink-0" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M3 4h14l4 4v12H3z"/><path d="M7 10l3 3-3 3"/><path d="M12.5 16H17"/></svg></span><span class="truncate" translate="no">terminal</span></div><div class="relative" style="--doc-prompt:&quot;$ &quot;"><div class="CodeBlock group/code !my-0 !rounded-none !border-0 [&amp;_pre]:!overflow-x-visible [&amp;_.line-hl]:inline-block [&amp;_.line-hl]:min-w-[calc(100%+4.1rem)] [&amp;_.line-hl]:-ml-[1.1rem] [&amp;_.line-hl]:pl-[calc(1.1rem-3px)] [&amp;_.line-hl]:pr-12 [&amp;_.line-hl]:align-top [&amp;_.line-hl]:h-5 [&amp;_.line-hl]:border-l-[3px] [&amp;_.line-hl]:border-accent [&amp;_.line-hl]:bg-accent/[0.09] [&amp;_.line:not(:empty):has(span)]:before:content-[var(--doc-prompt)] [&amp;_.line]:before:select-none [&amp;_.line]:before:text-fg-faint [&amp;_.line:has(&gt;
1.s-6272a4:first-child)]:before:content-none"><div class="relative"><div class="CodeBlockScroll"><div data-h="1"><pre class="shiki"><code><span class="line"><span class="s-f8f8f2">bun run start                 </span><span class="s-6272a4"># run the `start` script</span></span>
2<span class="line"><span class="s-f8f8f2">bun install </span><span class="s-ff79c6">&lt;</span><span class="s-f8f8f2">pkg</span><span class="s-ff79c6">&gt;</span><span class="s-f8f8f2">             </span><span class="s-6272a4"># install a package</span></span>
3<span class="line"><span class="s-f8f8f2">bun build ./index.tsx         </span><span class="s-6272a4"># bundle a project for browsers</span></span>
4<span class="line"><span class="s-f8f8f2">bun </span><span class="s-8be9fd">test</span><span class="s-f8f8f2">                      </span><span class="s-6272a4"># run tests</span></span>
5<span class="line"><span class="s-f8f8f2">bunx cowsay </span><span class="s-e9f284">&#39;</span><span class="s-f1fa8c">Hello, world!</span><span class="s-e9f284">&#39;</span><span class="s-f8f8f2">   </span><span class="s-6272a4"># execute a package</span></span></code></pre></div></div><button type="button" aria-label="Copy to clipboard" class="CopyIcon group/copy inline-flex items-center justify-center rounded-md text-fg-faint transition-[color,background,opacity] hover:bg-fg/[0.06] hover:text-fg h-7 w-7 copy absolute right-1.5 top-[-3px]"><span class="relative block h-4 w-4"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="absolute inset-0 h-4 w-4 transition-[opacity,transform] duration-200 opacity-100"><path d="M5.5 16H3V3h13v2.5"></path><path d="M8 8h9l4 4v9H8z"></path></svg><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="absolute inset-0 h-4 w-4 text-success transition-[opacity,transform] duration-200 scale-75 opacity-0"><path d="M4 12l5 5L20 6"></path></svg></span></button></div></div></div></div><h2 id="what-is-a-runtime" class="anchored">What is a runtime?<a href="#what-is-a-runtime" aria-label="Permalink" data-pagefind-ignore="" class="anchor">#</a></h2><p>JavaScript (or, more formally, ECMAScript) is only a <em>specification</em> for a programming language. Anyone can write a JavaScript <em>engine</em> that ingests a valid JavaScript program and executes it. The two most popular engines in use today are V8 (developed by Google)
6and JavaScriptCore (developed by Apple). Both are open source.</p><p>But most JavaScript programs don&#x27;t run in a vacuum. They need a way to access the outside world to perform useful tasks. This is where <em>runtimes</em> come in. They implement additional APIs and make them available to the JavaScript programs they execute.</p><h3 id="browsers" class="anchored">Browsers<a href="#browsers" aria-label="Permalink" data-pagefind-ignore="" class="anchor">#</a></h3><p>Browsers ship with JavaScript runtimes that implement a set of Web-specific APIs, exposed on the global <code>window</code> object. Any JavaScript code executed by the browser can use these APIs to add interactive or dynamic behavior to the current webpage.</p><h3 id="node-js" class="anchored">Node.js<a href="#node-js" aria-label="Permalink" data-pagefind-ignore="" id="nodejs" class="anchor">#</a></h3><p>Node.js is a JavaScript runtime for non-browser environments, like servers. JavaScript programs executed by Node.js have access to a set of Node.js-specific <a href="https://nodejs.org/api/globals.html" target="_blank" rel="noopener noreferrer">globals</a> like <code>Buffer</code>, <code>process</code>, and <code>__dirname</code> in addition to built-in modules for OS-level tasks like reading/writing files (<code>node:fs</code>) and networking (<code>node:net</code>, <code>node:http</code>). Node.js also implements a CommonJS-based module system and resolution algorithm that pre-dates JavaScript&#x27;s native module system.</p><p>Bun is designed as a faster, leaner, more modern replacement for Node.js.</p><h2 id="design-goals" class="anchored">Design goals<a href="#design-goals" aria-label="Permalink" data-pagefind-ignore="" class="anchor">#</a></h2><p>Bun is designed from the ground-up with today&#x27;
6s JavaScript ecosystem in mind.</p><ul><li><strong>Speed</strong>. Bun processes start <a href="https://twitter.com/jarredsumner/status/1499225725492076544" target="_blank" rel="noopener noreferrer">4x faster than Node.js</a>.</li><li><strong>TypeScript &amp; JSX support</strong>. You can directly execute <code>.jsx</code>, <code>.ts</code>, and <code>.tsx</code> files; Bun&#x27;s transpiler converts these to vanilla JavaScript before execution.</li><li><strong>ESM &amp; CommonJS compatibility</strong>. The world is moving towards ES modules (ESM), but millions of packages on npm still require CommonJS. Bun recommends ES modules, but supports CommonJS.</li><li><strong>Web-standard APIs</strong>. Bun implements standard Web APIs like <code>fetch</code>, <code>WebSocket</code>, and <code>ReadableStream</code>. Bun is powered by the JavaScriptCore engine, which is developed by Apple for Safari, so some APIs like <a href="https://developer.mozilla.org/en-US/docs/Web/API/Headers" target="_blank" rel="noopener noreferrer"><code>Headers</code></a> and <a href="https://developer.mozilla.org/en-US/docs/Web/API/URL" target="_blank" rel="noopener noreferrer"><code>URL</code></a> directly use <a href="https://github.com/oven-sh/bun/blob/HEAD/src/jsc/bindings/webcore/JSFetchHeaders.cpp" target="_blank" rel="noopener noreferrer">Safari&#x27;s implementation</a>.</li><li><strong>Node.js compatibility</strong>. In addition to supporting Node-style module resolution, Bun aims for full compatibility with built-in Node.js globals (<code>process</code>, <code>Buffer</code>) and modules (<code>path</code>, <code>fs</code>, <code>http</code>). <em>This is an ongoing effort.</em> See <a href="/docs/runtime/nodejs-compat">Node.js compatibility</a> for the current status.</li></ul><p>Bun is more than a runtime. The long-term goal is a cohesive, infrastructural toolkit for building apps with JavaScript/TypeScript: a package manager, transpiler, bundler, script runner, and test runner.</p></div><footer class="mt-16 flex flex-col gap-8"><nav aria-label="Pagination" data-pagefind-ignore="true" class="grid gap-4 sm:grid-cols-2"><span></span><a class="group/n flex flex-col gap-1 rounded-2xl border border-line bg-surface p-4 transition-colors hover:border-line-strong items-end text-right" href="/docs/installation" data-link="" data-prefetch="true"><span class="label">Next</span><span class="flex items-center gap-2 text-[15px] font-medium text-fg"><span class="min-w-0">Installation</span><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-4 w-4 shrink-0 transition-transform group-hover/n:translate-x-0.5"><path d="M4 12h14"></path><path d="M13 6l6 6-6 6"></path></svg></span></a></nav><div class="flex flex-wrap items-center justify-between gap-4 border-t border-line pt-6 text-[13.5px] text-fg-faint"><a href="https://github.com/oven-sh/bun/blob/main/docs/index.mdx" target="_blank" rel="noopener" class="inline-flex items-center gap-2 text-fg-muted transition-colors hover:text-fg"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter" aria-hidden="true" class="h-4 w-4"><path d="M9.5 21v-3.5l1-1.5C7 15.5 5 14 5 10.5L6.5 8 6 4.5l3.5 1.5h5l3.5-1.5-.5 3.5 1.5 2.5c0 3.5-2 5-5.5 5.5l1 1.5V21"></path><path d="M9.5 18.5H7l-1.5-2L4 15.5"></path><rect x="8.5" y="9.75" width="1.75" height="2.25" fill="currentColor" stroke="none"></rect><rect x="13.75" y="9.75" width="1.75" height="2.25" fill="currentColor" stroke="none"></rect></svg>Edit this page on GitHub</a><a href="/docs.md" class="mono text-[12px] uppercase tracking-[0.12em] transition-colors hover:text-fg">View as Markdown</a></div></footer></article></div></div></div></main><button type="button" aria-label="Ask AI about Bun" class="ask-fab fixed bottom-4 right-4 z-[110] inline-flex h-10 items-center gap-2 border border-rule bg-canvas px-3.5 text-[13.5px] font-medium text-fg shadow-[0_2px_10px_rgba(0,0,0,0.12)] transition-colors hover:bg-subtle print:hidden"><span class="t-icon inline-flex shrink-0 [&amp;&gt;svg]:h-full [&amp;&gt;svg]:w-full h-4 w-4" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="square" stroke-linejoin="miter"><path d="M9 7l2 4.5 4.5 2-4.5 2L9 20l-2-4.5-4.5-2L7 11.5z"/><path d="M18 2l1.25 2.75L22 6l-2.75 1.25L18 10l-1.25-2.75L14 6l2.75-1.25z" fill="currentColor" stroke="none"/><path d="M18.5 16.5v4M16.5 18.5h4"/></svg></span>Ask AI</button></div></div>
6<script id="__bun_data" type="application/json">{"section":"docs","url":"/docs","meta":{"title":"Welcome to Bun","description":"Bun is an all-in-one toolkit for developing modern JavaScript/TypeScript applications.","mode":"center"},"tree":[{"$$mdtype":"Tag","name":"CardGroup","attributes":{},"children":[{"$$mdtype":"Tag","name":"Card","attributes":{"icon":"cog","title":"Bun Runtime","href":"/docs/runtime","cta":{"$$mdtype":"Tag","name":"span","attributes":{},"children":["Get started with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["bun run"]}]}},"children":[{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["A fast JavaScript runtime designed as a drop-in replacement for Node.js"]}]},{"$$mdtype":"Tag","name":"Card","attributes":{"icon":"box","title":"Bun Package Manager","href":"/docs/pm/cli/install","cta":{"$$mdtype":"Tag","name":"span","attributes":{},"children":["Get started with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["bun install"]}]}},"children":[{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["Install packages up to 30x faster than npm with a global cache and workspaces"]}]},{"$$mdtype":"Tag","name":"Card","attributes":{"icon":"flask-conical","title":"Bun Test Runner","href":"/docs/test","cta":{"$$mdtype":"Tag","name":"span","attributes":{},"children":["Get started with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["bun test"]}]}},"children":[{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["Jest-compatible, TypeScript-first tests with snapshots, DOM, and watch mode"]}]},{"$$mdtype":"Tag","name":"Card","attributes":{"icon":"combine","title":"Bun Bundler","href":"/docs/bundler","cta":{"$$mdtype":"Tag","name":"span","attributes":{},"children":["Get started with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["bun build"]}]}},"children":[{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["Bundle TypeScript, JSX, React & CSS for both browsers and servers"]}]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"h2","attributes":{"id":"get-started","class":"anchored"},"children":["Get Started",{"$$mdtype":"Tag","name":"a","attributes":{"href":"#get-started","class":"anchor","aria-label":"Permalink","data-pagefind-ignore":""},"children":["#"]}]},{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["Bun ships as a single, dependency-free binary and includes a runtime, package manager, test runner, and bundler. New to Bun?"]},{"$$mdtype":"Tag","name":"CardGroup","attributes":{},"children":[{"$$mdtype":"Tag","name":"Card","attributes":{"icon":"download","title":"Install Bun","href":"/docs/installation"},"children":[{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["Supported platforms and all install methods."]}]},{"$$mdtype":"Tag","name":"Card","attributes":{"icon":"zap","title":"Quickstart","href":"/docs/quickstart"},"children":[{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["Hello world in minutes with Bun.serve."]}]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"h2","attributes":{"id":"what-s-inside","class":"anchored"},"children":["What's Inside",{"$$mdtype":"Tag","name":"a","attributes":{"href":"#what-s-inside","class":"anchor","aria-label":"Permalink","data-pagefind-ignore":"","id":"whats-inside"},"children":["#"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"ListItem","attributes":{},"children":["Runtime: Execute JavaScript/TypeScript files and package scripts with near-zero overhead."]},{"$$mdtype":"Tag","name":"ListItem","attributes":{},"children":["Package Manager: Fast installs, workspaces, overrides, and audits with ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["bun install"]},"."]},{"$$mdtype":"Tag","name":"ListItem","attributes":{},"children":["Test Runner: Jest-compatible, TypeScript-first tests with snapshots, DOM, and watch mode."]},{"$$mdtype":"Tag","name":"ListItem","attributes":{},"children":["Bundler: Native bundling for JS/TS/JSX with splitting, plugins, and HTML imports."]}]},{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["Explore each area using the cards above. Each section is structured with an overview, short examples, reference, and best practices for fast scanning and deep dives."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"h2","attributes":{"id":"what-is-bun","class":"anchored"},"children":["What is Bun?",{"$$mdtype":"Tag","name":"a","attributes":{"href":"#what-is-bun","class":"anchor","aria-label":"Permalink","data-
6pagefind-ignore":""},"children":["#"]}]},{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["bun"]},"."]},{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["At its core is the ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Bun runtime"]},", a fast JavaScript runtime designed as ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["a drop-in replacement for Node.js"]},". It's written in Rust and powered by JavaScriptCore, reducing startup time and memory usage."]},{"$$mdtype":"Tag","name":"Fence","attributes":{"block":{"lang":"bash","segments":[{"kind":"code","h":0}]},"language":"bash","title":"terminal","icon":"terminal"},"children":[]},{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["bun"]}," command-line tool also implements a test runner, script runner, and Node.js-compatible package manager. All three are significantly faster than existing tools, and you can use them in existing Node.js projects with little to no changes."]},{"$$mdtype":"Tag","name":"Fence","attributes":{"block":{"lang":"bash","segments":[{"kind":"code","h":1}]},"language":"bash","title":"terminal","icon":"terminal"},"children":[]},{"$$mdtype":"Tag","name":"h2","attributes":{"id":"what-is-a-runtime","class":"anchored"},"children":["What is a runtime?",{"$$mdtype":"Tag","name":"a","attributes":{"href":"#what-is-a-runtime","class":"anchor","aria-label":"Permalink","data-pagefind-ignore":""},"children":["#"]}]},{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["JavaScript (or, more formally, ECMAScript) is only a ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["specification"]}," for a programming language. Anyone can write a JavaScript ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["engine"]}," that ingests a valid JavaScript program and executes it. The two most popular engines in use today are V8 (developed by Google)\nand JavaScriptCore (developed by Apple). Both are open source."]},{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["But most JavaScript programs don't run in a vacuum. They need a way to access the outside world to perform useful tasks. This is where ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["runtimes"]}," come in. They implement additional APIs and make them available to the JavaScript programs they execute."]},{"$$mdtype":"Tag","name":"h3","attributes":{"id":"browsers","class":"anchored"},"children":["Browsers",{"$$mdtype":"Tag","name":"a","attributes":{"href":"#browsers","class":"anchor","aria-label":"Permalink","data-pagefind-ignore":""},"children":["#"]}]},{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["Browsers ship with JavaScript runtimes that implement a set of Web-specific APIs, exposed on the global ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["window"]}," object. Any JavaScript code executed by the browser can use these APIs to add interactive or dynamic behavior to the current webpage."]},{"$$mdtype":"Tag","name":"h3","attributes":{"id":"node-js","class":"anchored"},"children":["Node.js",{"$$mdtype":"Tag","name":"a","attributes":{"href":"#node-js","class":"anchor","aria-label":"Permalink","data-pagefind-ignore":"","id":"nodejs"},"children":["#"]}]},{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["Node.js is a JavaScript runtime for non-browser environments, like servers. JavaScript programs executed by Node.js have access to a set of Node.js-specific ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"https://nodejs.org/api/globals.html"},"children":["globals"]}," like ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["Buffer"]},", ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["process"]},", and ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["__dirname"]}," in addition to built-in modules for OS-level tasks like reading/writing files (",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["node:fs"]},") and networking (",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["node:net"]},", ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["node:http"]},"). Node.js also implements a CommonJS-based module system and resolution algorithm that pre-dates JavaScript's native module system."]},{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["Bun is designed as a faster, leaner, more modern replacement for Node.js."]},{"$$mdtype":"Tag","name":"h2","attributes":{"id":"design-goals","class":"anchored"},"children":["Design goals",{"$$mdtype":"Tag","name":"a","attributes":{"href":"#design-goals","class":"anchor","aria-label":"Permalink","data-
6pagefind-ignore":""},"children":["#"]}]},{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["Bun is designed from the ground-up with today's JavaScript ecosystem in mind."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"ListItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Speed"]},". Bun processes start ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"https://twitter.com/jarredsumner/status/1499225725492076544"},"children":["4x faster than Node.js"]},"."]},{"$$mdtype":"Tag","name":"ListItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["TypeScript & JSX support"]},". You can directly execute ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":[".jsx"]},", ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":[".ts"]},", and ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":[".tsx"]}," files; Bun's transpiler converts these to vanilla JavaScript before execution."]},{"$$mdtype":"Tag","name":"ListItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["ESM & CommonJS compatibility"]},". The world is moving towards ES modules (ESM), but millions of packages on npm still require CommonJS. Bun recommends ES modules, but supports CommonJS."]},{"$$mdtype":"Tag","name":"ListItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Web-standard APIs"]},". Bun implements standard Web APIs like ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["fetch"]},", ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["WebSocket"]},", and ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["ReadableStream"]},". Bun is powered by the JavaScriptCore engine, which is developed by Apple for Safari, so some APIs like ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"https://developer.mozilla.org/en-US/docs/Web/API/Headers"},"children":[{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["Headers"]}]}," and ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"https://developer.mozilla.org/en-US/docs/Web/API/URL"},"children":[{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["URL"]}]}," directly use ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"https://github.com/oven-sh/bun/blob/HEAD/src/jsc/bindings/webcore/JSFetchHeaders.cpp"},"children":["Safari's implementation"]},"."]},{"$$mdtype":"Tag","name":"ListItem","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Node.js compatibility"]},". In addition to supporting Node-style module resolution, Bun aims for full compatibility with built-in Node.js globals (",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["process"]},", ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["Buffer"]},") and modules (",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["path"]},", ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["fs"]},", ",{"$$mdtype":"Tag","name":"Code","attributes":{},"children":["http"]},"). ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["This is an ongoing effort."]}," See ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/docs/runtime/nodejs-compat"},"children":["Node.js compatibility"]}," for the current status."]}]},{"$$mdtype":"Tag","name":"Paragraph","attributes":{},"children":["Bun is more than a runtime. The long-term goal is a cohesive, infrastructural toolkit for building apps with JavaScript/TypeScript: a package manager, transpiler, bundler, script runner, and test runner."]}],"headings":[{"content":"Get Started","level":2,"id":"get-started"},{"content":"What's Inside","level":2,"id":"what-s-inside"},{"content":"What is Bun?","level":2,"id":"what-is-bun"},{"content":"What is a runtime?","level":2,"id":"what-is-a-runtime"},{"content":"Browsers","level":3,"id":"browsers"},{"content":"Node.js","level":3,"id":"node-js"},{"content":"Design goals","level":2,"id":"design-goals"}],"sidebar":{"tabs":[{"title":"Runtime","tab":"Runtime","href":"/docs","external":false,"current":true,"icon":"cog"},{"title":"Package Manager","tab":"Package Manager","href":"/docs/pm/cli
6/install","external":false,"current":false,"icon":"box"},{"title":"Bundler","tab":"Bundler","href":"/docs/bundler","external":false,"current":false,"icon":"combine"},{"title":"Test Runner","tab":"Test Runner","href":"/docs/test","external":false,"current":false,"icon":"flask-conical"},{"title":"Guides","tab":"Guides","href":"/guides","external":false,"current":false,"icon":"map"},{"title":"Reference","tab":"Reference","href":"/reference","external":false,"current":false,"icon":"book"},{"title":"Blog","tab":"Blog","href":"/blog","external":false,"current":false,"icon":"newspaper"},{"title":"Feedback","tab":"Feedback","href":"/docs/feedback","external":false,"current":false,"icon":"lightbulb"}],"groups":[{"title":"Get Started","group":"Get Started","pages":[{"title":"Welcome to Bun","href":"/docs","current":true},{"title":"Installation","href":"/docs/installation"},{"title":"Quickstart","href":"/docs/quickstart"},{"title":"TypeScript","href":"/docs/typescript"},{"title":"TypeScript 6 and 7","href":"/docs/typescript-6"},{"title":"bun init","href":"/docs/runtime/templating/init"},{"title":"bun create","href":"/docs/runtime/templating/create"}],"icon":"terminal"},{"title":"Core Runtime","group":"Core Runtime","pages":[{"title":"Bun Runtime","href":"/docs/runtime"},{"title":"Watch Mode","href":"/docs/runtime/watch-mode"},{"title":"Debugging","href":"/docs/runtime/debugger"},{"title":"REPL","href":"/docs/runtime/repl"},{"title":"bunfig.toml","href":"/docs/runtime/bunfig"}],"icon":"cog"},{"title":"File & Module System","group":"File & Module System","pages":[{"title":"File Types","href":"/docs/runtime/file-types"},{"title":"Module Resolution","href":"/docs/runtime/module-resolution"},{"title":"JSX","href":"/docs/runtime/jsx"},{"title":"Auto-install","href":"/docs/runtime/auto-install"},{"title":"Plugins","href":"/docs/runtime/plugins"},{"title":"File System Router","href":"/docs/runtime/file-system-router"}],"icon":"file"},{"title":"HTTP server","group":"HTTP server","pages":[{"title":"Server","href":"/docs/runtime/http/server"},{"title":"Routing","href":"/docs/runtime/http/routing"},{"title":"Cookies","href":"/docs/runtime/http/cookies"},{"title":"TLS","href":"/docs/runtime/http/tls"},{"title":"Error Handling","href":"/docs/runtime/http/error-handling"},{"title":"Metrics","href":"/docs/runtime/http/metrics"}],"icon":"server"},{"title":"Networking","group":"Networking","pages":[{"title":"Fetch","href":"/docs/runtime/networking/fetch"},{"title":"WebSockets","href":"/docs/runtime/http/websockets"},{"title":"TCP","href":"/docs/runtime/networking/tcp"},{"title":"UDP","href":"/docs/runtime/networking/udp"},{"title":"DNS","href":"/docs/runtime/networking/dns"}],"icon":"globe","expanded":true},{"title":"Data & Storage","group":"Data & Storage","pages":[{"title":"Cookies","href":"/docs/runtime/cookies"},{"title":"File I/O","href":"/docs/runtime/file-io"},{"title":"Streams","href":"/docs/runtime/streams"},{"title":"Binary Data","href":"/docs/runtime/binary-data"},{"title":"Archive","href":"/docs/runtime/archive"},{"title":"SQL","href":"/docs/runtime/sql"},{"title":"SQLite","href":"/docs/runtime/sqlite"},{"title":"S3","href":"/docs/runtime/s3"},{"title":"Redis","href":"/docs/runtime/redis"}],"icon":"database"},{"title":"Concurrency","group":"Concurrency","pages":[{"title":"Workers","href":"/docs/runtime/workers"},{"title":"ModuleGraph","href":"/docs/runtime/module-graph"}],"icon":"split"},{"title":"Process & System","group":"Process & System","pages":[{"title":"Environment Variables","href":"/docs/runtime/environment-variables"},{"title":"Shell","href":"/docs/runtime/shell"},{"title":"Spawn","href":"/docs/runtime/child-process"},{"title":"WebView","href":"/docs/runtime/webview"},{"title":"Cron","href":"/docs/runtime/cron"}],"icon":"computer"},{"title":"Interop & Tooling","group":"Interop & Tooling","pages":[{"title":"Node-API","href":"/docs/runtime/node-api"},{"title":"FFI","href":"/docs/runtime/ffi"},{"title":"C Compiler","href":"/docs/runtime/c-compiler"},{"title":"Transpiler","href":"/docs/runtime/transpiler"}],"icon":"puzzle"},{"title":"Utilities","group":"Utilities","pages":[{"title":"CSRF Protection","href":"/docs/runtime/csrf"},{"title":"Secrets","href":"/docs/runtime/secrets"},{"title":"Console","href":"/docs/runtime/console"},{"title":"TOML","href":"/docs/runtime/toml"},{"title":"YAML","href":"/docs/runtime/yaml"},{"title":"Markdown","href":"/docs/runtime/markdown"},{"title":"JSON5","href":"/docs/runtime/json5"},{"title":"XML","href":"/docs/runtime/xml"},{"title":"JSONL","href":"/docs/runtime/jsonl"},{"title":"HTMLRewriter","href":"/docs/runtime/html-rewriter"},{"title":"Image","href":"/docs/runtime/image"},{"title":"Hashing","href":"/docs/runtime/hashing"},{"title":"Glob","href":"/docs/runtime/glob"},{"title":"Semver","href":"/docs/runtime/semver"},{"title":"Color","href":"/docs/runtime/color"},{"title":"Utils","href":"/docs/runtime/utils"}],"icon":"wrench"},{"title":"Standards & Compatibility","group":"Standards & Compatibility","pages":[{"title":"Globals","href":"/docs/runtime/globals"},{"title":"Bun APIs","href":"/docs/runtime/bun-apis"},{"title":"Web APIs","href":"/docs/runtime/web-apis"},{"title":"Node.js Compatibility","href":"/docs/runtime/nodejs-compat"}],"icon":"badge-check"},{"title":"Contributing","group":"Contributing","pages":[{"title":"Roadmap","href":"/docs/project/roadmap"},{"title":"Benchmarking","href":"/docs/project/benchmarking"},{"title":"Contributing","href":"/docs/project/contributing"},{"title":"Building Windows","href":"/docs/project/building-windows"},{"title":"Bindgen","href":"/docs/project/bindgen"}
6,{"title":"License","href":"/docs/project/license"}],"icon":"heart"}]},"breadcrumbs":[{"title":"Runtime","href":"/docs"},{"title":"Get Started"},{"title":"Welcome to Bun","href":"/docs"}],"prev":null,"next":{"title":"Installation","href":"/docs/installation"},"editUrl":"https://github.com/oven-sh/bun/blob/main/docs/index.mdx","sourceFile":"index.mdx","diagnostics":[]}</script>
6<script type="module" src="/_assets/page-docs-index-693w1vxg.js"></script>
6<script defer="" src="/_assets/analytics-mxqb4sf1.js"></script>
6<script type="module" src="https://static.cloudflareinsights.com/beacon.min.js/v31edd6df95cf4e85bb4c19e7a9bdbcba1788362987495" integrity="sha512-iIg7k2xntmwu6/uSb5tpc/hySgZc4eoL31yB29W6tJFo2akwjPWcEqnCEdJvGexCL0KEQwVYv5BlowfhVz26hg==" data-cf-beacon='{"version":"2024.11.0","token":"c24e29d7664b496aa2b3c8bf0fd0ec9d","spa":2}' crossorigin="anonymous"></script>
6
7</body></html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.