Bun Runtime - BunDocumentation Index Search...⌘KInstall Bun Search...Navigation Core Runtime Bun RuntimeRuntimePackage ManagerBundlerTest RunnerGuidesReferenceBlogFeedback:first-child]:!hidden peer-[.is-custom]:[&>:first-child]:sm:!hidden peer-[.is-custom]:[&>:first-child]:md:!hidden peer-[.is-custom]:[&>:first-child]:lg:!hidden peer-[.is-custom]:[&>:first-child]:xl:!hidden">Get StartedWelcome to BunInstallationQuickstartTypeScriptTypeScript 6 and 7bun initbun createCore RuntimeBun RuntimeWatch ModeDebuggingREPLbunfig.tomlFile & Module SystemFile TypesModule ResolutionJSXAuto-installPluginsFile System RouterHTTP serverServerRoutingCookiesTLSError HandlingMetricsNetworkingFetchWebSocketsTCPUDPDNSData & StorageCookiesFile I/OStreamsBinary DataArchiveSQLSQLiteS3RedisConcurrencyWorkersProcess & SystemEnvironment VariablesShellSpawnWebViewCronInterop & ToolingNode-APIFFIC CompilerTranspilerUtilitiesCSRF ProtectionSecretsConsoleTOMLYAMLMarkdownJSON5JSONLHTMLRewriterImageHashingGlobSemverColorUtilsStandards & CompatibilityGlobalsBun APIsWeb APIsNode.js CompatibilityContributingRoadmapBenchmarkingContributingBuilding WindowsBindgenLicense On this pageRun a file--watchRun a package.json script--bunFilteringbun run - to pipe code from stdinbun run --console-depthbun run --smolResolution orderCLI UsageGeneral Execution OptionsWorkspace ManagementRuntime & Process ControlDevelopment WorkflowDebuggingDependency & Module ResolutionTranspilation & Language FeaturesNetworking & SecurityGlobal Configuration & ContextExamplesCore RuntimeBun Runtime Copy pagespan]:line-clamp-1 overflow-hidden group flex items-center py-0.5 gap-1 text-sm text-gray-950/50 dark:text-white/50 group-hover:text-gray-950/70 dark:group-hover:text-white/70 rounded-none rounded-r-xl border px-3 border-gray-200 aspect-square dark:border-white/[0.07] bg-background-light dark:bg-background-dark hover:bg-gray-600/5 dark:hover:bg-gray-200/5" aria-label="More actions" type="button" id="radix-_R_n4ctdbsnlht5lebsnpfdb_" aria-haspopup="menu" aria-expanded="false" data-state="closed"> *]:[overflow-wrap:anywhere]"> Copy pagespan]:line-clamp-1 overflow-hidden group flex items-center py-0.5 gap-1 text-sm text-gray-950/50 dark:text-white/50 group-hover:text-gray-950/70 dark:group-hover:text-white/70 rounded-none rounded-r-xl border px-3 border-gray-200 aspect-square dark:border-white/[0.07] bg-background-light dark:bg-background-dark hover:bg-gray-600/5 dark:hover:bg-gray-200/5" aria-label="More actions" type="button" id="radix-_R_1cctdbsnlht5lebsnpfdb_" aria-haspopup="menu" aria-expanded="false" data-state="closed"> The Bun Runtime is designed to start fast and run fast.
Under the hood, Bun uses the JavaScriptCore engine, which is developed by Apple for Safari. In most cases, the startup and running performance is faster than V8, the engine used by Node.js and Chromium-based browsers. Its transpiler and runtime are written in Zig, a modern, high-performance language. On Linux, this translates into startup times 4x faster than Node.js.
CommandTimebun hello.js5.2msnode hello.js25.1ms
This benchmark is based on running a Hello World script on Linux
Run a file
Use bun run to execute a source file.
terminal When using bun run, put Bun flags like --watch immediately after bun. Compare to npm run
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
Skip to main contentBun home pageExecute JavaScript/TypeScript files, package.json scripts, and executable packages with Bun’s fast runtime.
bun run index.jsBun supports TypeScript and JSX out of the box. Every file is transpiled on the fly by Bun’s fast native transpiler before being executed. terminal
bun run index.js bun run index.jsx bun run index.ts bun run index.tsxAlternatively, you can omit the run keyword and use the “naked” command; it behaves identically. terminal
bun index.tsx bun index.js--watch To run a file in watch mode, use the --watch flag. terminal
bun --watch run index.tsx
bun --watch run dev # ✔️ do this bun run dev --watch # ❌ don't do thisFlags that occur at the end of the command will be ignored and passed through to the "dev" script itself. Run a package.json script
Bun Runtime - Bun,AI智能索引,全网链接索引,智能导航,网页索引
- Execute JavaScript/TypeScript files, package.json scripts, and executable packages with Bun