Running Node.js in the Browser: How StackBlitz WebContainers Work and Where They Break
StackBlitz runs Node.js dev servers inside the browser via WebAssembly, not on a remote VM. Here's how WebContainers boot a project, a worked Vite and embed-SDK example, and the hard limits to plan around.
15 Feb 2026, 21:03 UTC

If you need a reproducible dev environment that a teammate can open from a link — for a bug report, a docs demo, or a workshop — StackBlitz is often the right answer, and the reason is WebContainers: a runtime that executes Node.js inside the browser tab itself, via WebAssembly, instead of proxying your commands to a remote VM. That single design decision changes the latency, cost, and capability profile of the whole product, and understanding it tells you exactly where StackBlitz fits and where it will fail you.
What "Node.js in the browser" actually means
Traditional cloud dev environments (Codespaces, Gitpod) boot a Linux container on a server and stream a terminal and editor to you. StackBlitz does the opposite: it ships a Node.js-compatible runtime to your browser, compiled to WebAssembly. When you run npm install or npm run dev in a StackBlitz project, the work happens locally in the tab — package installs, file watching, and the dev server all execute against a virtual filesystem in browser memory.
The practical consequences:
- No provisioning step. There is no container to allocate per user, so projects open in seconds rather than the boot time of a remote VM.
- Local-speed installs. Dependency installation does not round-trip to a datacenter for every file operation.
- Server-side cost is minimal. StackBlitz is not paying to run your dev server, which is why sharing links at scale is cheap.
- Hard capability ceiling. If the runtime cannot emulate it in WebAssembly, it does not run. More on that below.
A worked example: a Vite project with zero special config
The most common StackBlitz use case needs no StackBlitz-specific configuration at all. A standard Vite project works as-is:
{
"name": "repro-demo",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"vite": "^5.4.0"
}
}When this project opens on stackblitz.com, the platform detects the dev script, runs npm install in the browser, starts Vite, and automatically forwards the dev server's port to a preview URL shown in an embedded pane. You never configure port mapping — StackBlitz proxies whatever port the dev server binds to.
Two decisions make this reproducible for reviewers:
- Pin dependency versions (or use exact versions) in
package.jsonrather than wide ranges. - Commit the lockfile (
package-lock.json,pnpm-lock.yaml, oryarn.lock). Because every viewer's environment is otherwise identical — same runtime, same files — the lockfile is what guarantees they resolve the same dependency tree you did.
Package managers npm, pnpm, and yarn are all supported; the runtime picks up whichever lockfile is present.
Embedding live projects in documentation
A common docs-engineering decision is embedding an editable, runnable project directly in a tutorial instead of pasting static snippets. The official SDK (@stackblitz/sdk) does this from any static page:
import sdk from '@stackblitz/sdk';
sdk.embedProject(
document.getElementById('embed'),
{
title: 'Fetch demo',
template: 'node',
files: {
'index.js': `console.log('hello from a WebContainer');`,
'package.json': JSON.stringify({
scripts: { start: 'node index.js' }
})
}
},
{ openFile: 'index.js' }
);Run this in any bundler-based site after npm install @stackblitz/sdk; no special permissions are needed since everything executes client-side in an iframe. sdk.openProject is the alternative when you want a full new tab instead of an inline embed. The embedded instance boots the same WebContainer runtime, so readers can edit files and rerun the dev server without leaving your page.
Where WebContainers break: the limits to plan around
Every limit below follows from the same root cause — the runtime is WebAssembly in a browser sandbox, not Linux.
Node.js toolchains only
Vite, Next.js dev mode, most test runners, and anything else built on Node.js generally work. Python, Ruby, Go, Rust toolchains, or anything requiring a non-Node language server do not. If your stack's dev server is not a Node process, StackBlitz is the wrong tool.
No native binaries, raw sockets, or Docker
Packages with native modules that need system libraries (some image processors, certain database drivers) will fail to install or run. Databases like PostgreSQL cannot run inside the tab — mock them, use an in-memory alternative, or point the app at an externally hosted instance. Docker is unavailable by definition; there is no kernel to containerize against.
Browser memory and storage ceilings
The virtual filesystem and build process live in browser memory. Large monorepos or heavy builds that are merely slow on a laptop can fail outright in a tab. If your repro needs the whole monorepo, trim it to the minimal package that demonstrates the problem — which is good practice for bug reports anyway.
Preview networking goes through a proxy
The preview URL is proxied by StackBlitz, so CORS behavior, cookie attributes (especially SameSite and third-party cookie rules), and service worker scope can differ subtly from production hosting. Treat the preview as a development signal, not a deployment validation. If a bug only reproduces under real hosting conditions, StackBlitz may mask it.
Common mistakes
- Sharing a repro without a lockfile. The reviewer resolves different transitive dependencies and cannot reproduce your bug.
- Assuming "works in StackBlitz" means "works in production." The proxied preview hides CORS and cookie issues.
- Trying to demo a full-stack app with a real database. Plan for a mock API layer or a hosted dev database reachable over HTTPS.
- Targeting non-Chromium browsers without testing. Chromium-based browsers have historically had the most complete WebContainer support; verify current browser support in the official docs before rolling out to a team.
How to verify it fits your project
Before committing, spend ten minutes on a smoke test: push your project (or a minimal slice of it) to a new StackBlitz project, confirm npm install completes and the dev server boots with no cloud-VM setup step, and exercise the one risky dependency you have — a native module, a database client, an unusual build plugin. If that passes, check the official WebContainers documentation's supported-tooling and limitations sections, since feature support and browser compatibility change over time and the details here reflect general behavior rather than a guaranteed current state.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.