Bun playground
Docs

Bun Playground: Run Bun in your browser

Write TypeScript, install packages with bun install and serve apps with Bun.serve, all in a browser tab. Built from Bun's own Rust crates compiled to WebAssembly: no install, no server, no account.

Read the docs

What it is

runbun.dev is a Bun playground that runs entirely in your browser tab. Write TypeScript, install packages from npm with bun install, run tests with bun test and serve an app with Bun.serve, without installing Bun, creating an account or sending your code to a server. Projects are saved in your browser, and a share link carries a whole project, so a bug reproduction is one URL.

const server = Bun.serve({
  routes: {
    "/": () => new Response(`Hello from Bun ${Bun.version}!`),
    "/api/time": () =>
      Response.json({ now: new Date(), bun: Bun.version }),
  },
});
console.log(`Listening on ${server.url}`);

Embed it in tutorials and demos

The live example above is an embed: one element in this page's HTML. Put the same thing in a tutorial, a blog post, a talk or your library's docs, and readers run and edit the code right where they read about it. It runs in their browser, so there is no backend to host.

  • Tutorials: give a lesson tests the reader doesn't see, and check their code against them; their edits are still there on the next visit
  • Demos: show a Bun.serve app's preview, a console or the whole playground, started on a click
  • Docs: @runbun/astro turns the code blocks of an Astro site into runnable ones

Embedding guide Build a snippet

<script type="module"
  src="https://runbun.dev/embed.js"></script>

<bun-playground mode="code" persist="lesson-1">
  <script type="text/plain" data-file="index.ts">
    export const add = (a: number, b: number) => 0;
  </script>
  <!-- Your checks: the reader never sees them. -->
  <script type="text/plain" data-file="add.test.ts"
    data-generated>
    import { test, expect } from "bun:test";
    import { add } from "./index";
    test("adds", () => expect(add(1, 2)).toBe(3));
  </script>
</bun-playground>

How it works

runbun.dev runs Bun client-side by compiling Bun's own Rust crates to 64-bit WebAssembly (wasm64): the transpiler, module resolver, bundler, formatter and semver are Bun's code, not lookalikes. Your code runs in the browser's JavaScript engine inside a Web Worker, where the Bun.*, bun:* and node:* APIs are JavaScript shims over an in-memory virtual file system. A service worker serves your modules and puts the responses of a Bun.serve or node:http server in the preview pane. There is no remote container or VM: close the tab and nothing keeps running. The editor's completions, hovers and type errors come from TypeScript 7's language service, also compiled to WebAssembly.

What works

  • Bun.serve with routes, WebSockets and streaming, previewed in the page
  • bun install from npm, with bun.lock; bun test; bun:sqlite
  • Bun.file, Bun.write, Bun.build (Bun's real bundler) and Bun.password
  • Frameworks: Elysia, Hono, Vite and the Astro dev server, with hot reload
  • TypeScript and JSX without a build step, and many node:* built-ins (fs, path, http, events, crypto)

Examples

What doesn't

It is not Bun itself. The runtime APIs are reimplemented in JavaScript, so coverage is uneven: a browser has no processes and no raw sockets, so Bun.spawn, Bun.connect, Bun.sql, bun:ffi and native .node addons are missing (Bun.$ runs Bun's builtins, not other programs). The compatibility pages list the status of every Bun API and Node built-in.

Browser support

Running code needs WebAssembly Memory64: Chrome and Edge 133+, and Firefox 134+. Safari, and every browser on iOS and iPadOS, open projects in edit-only mode until WebKit ships Memory64. Browser details.

Questions

Can I run Bun in the browser?

Yes. runbun.dev runs Bun projects in a browser tab. Bun's own transpiler, resolver, bundler, formatter and semver are compiled to WebAssembly, and the Bun.*, bun:* and node:* APIs are JavaScript shims. Most everyday code runs; processes, raw sockets and native addons don't. The compatibility pages list every API.

Is my code sent to a server?

No. Your code runs in your browser, and your projects are saved there. The browser only fetches packages from the npm registry when you install, and a GitHub repository when you open one. A short link stores a copy of a project on runbun.dev only when you choose to make one. See Privacy.

Which browsers does it work in?

Chrome and Edge 133+ and Firefox 134+ run code. Safari, and every browser on iOS and iPadOS, can open and edit projects but can't run them yet, because WebKit doesn't ship WebAssembly Memory64.

Which version of Bun is it?

Bun 1.4.4. Bun.version reports 1.4.4-browser, since the runtime APIs are reimplemented for the browser.

Does bun install work?

Yes. bun install fetches packages from npm into the project and caches them across projects, and installs the exact versions in an existing bun.lock. It doesn't write a bun.lock yet, and packages that need native .node addons can't load.

Is it free? Do I need an account?

It's free to use, and there is no account or sign-up.

Is runbun.dev an official Bun project?

No. runbun is an independent project, not affiliated with or endorsed by Oven or Bun.

Can I embed it in my own site?

Yes. Add the <bun-playground> element (from runbun.dev/embed.js or the @runbun/embed package) or an iframe, and your page gets a runnable Bun example. See Embedding.