Self-hosting
Clone BrowserCode, run it locally, customize it and deploy your own copy.
BrowserCode is open source under the Apache License 2.0. You can clone it, modify it and run your own copy, for example to add or remove agents or to replace the templates with your own. For how the license applies, including to BrowserPod and CheerpJ, see Licensing.
Running locally
You need Node.js 20.19+ or 22.12+, which the build tools require. The repo does not check the version, so older versions fail with unclear errors.
git clone https://github.com/leaningtech/browsercode.git
cd browsercode
npm install BrowserPod itself needs no key. Networking does: previews, repo cloning and agents use BrowserPod Edge, which requires an API key. Get one from the BrowserPod console and add it to a .env file. The key is read at build time and included in the built JavaScript,
so anyone who opens your copy can read it.
echo "VITE_API_KEY=your-key-here" > .env
npm run dev Open the URL that the dev server prints, in a browser that supports BrowserPod. The dev server sends the cross-origin isolation headers, so no further setup is needed.
Use port 5173 to run Codex. BrowserCode downloads the Codex binary at runtime,
from a host that only accepts requests from browsercode.io and localhost:5173. On any other port, Codex fails to install with "Failed to fetch".
The PORT environment variable changes the dev server's port, so make sure it is not set.
Running without an Edge key
Without an Edge API key, BrowserCode runs in keyless mode, with reduced functionality:
- Templates install and run, but have no live preview, because previews use BrowserPod portals.
- Cloning a repo and running an agent require a key, and show a message instead of booting.
- Java is unaffected, because it runs on CheerpJ.
Customizing
Most changes start in two files:
src/lib/config/tools.tsdefines the agents: which ones appear, what each one runs and how it signs in.src/lib/config/frameworks.tsdefines the templates. Their files are instatic/templates/.
Each template includes its own copy of the WebAssembly overrides that cloned repos get automatically. The build checks that these copies match and fails if one differs, so a template that cannot install is caught before you deploy it.
Deploying
npm run build outputs a static site to dist/, which you can deploy to
any static host. The host must:
- Send
Cross-Origin-Opener-Policy: same-originandCross-Origin-Embedder-Policy: require-corp. Without these headers, BrowserPod cannot useSharedArrayBufferand only Java projects run. The repo includes astatic/_headersfile for Cloudflare Pages. On other hosts, set the headers in the host's configuration. - Serve the SPA fallback,
404.html, for paths it does not recognize, with a 200 status for/ide/github/…. Repo clone URLs are resolved at runtime, so without it they fail.static/_redirectsdoes this on Cloudflare Pages.
Other scripts:
npm run previewserves the built site.npm run checkruns the type checker.npm run lintandnpm run formatrun ESLint and Prettier.
Contributing
Report bugs and suggest features in the issue tracker. If you found the bug in a modified copy, describe what you changed, because a modified build can fail differently from browsercode.io.