@nodebeey/webcontainer
v1.0.2
Published
Browser-native Node.js WebContainer — run npm install, Next.js, Vite, Express in the browser without a server
Maintainers
Readme
@nodebeey/webcontainer
Browser-native Node.js runtime. Embed a full Node.js environment — including npm install, Next.js, Vite, and Express — directly in your users' browsers. No server required.
Quick Start
npm install @nodebeey/webcontainerimport { WebContainer } from '@nodebeey/webcontainer'
// Boot a container (get your API key at nodebeey.com)
const container = await WebContainer.boot({ apiKey: 'nbee_live_...' })
// Mount files
await container.mount({
'package.json': {
file: { contents: JSON.stringify({ name: 'app', type: 'module' }) }
},
'index.js': {
file: { contents: 'console.log("Hello from the browser!")' }
}
})
// Run Node.js
const proc = await container.spawn('node', ['index.js'])
proc.output.pipeTo(new WritableStream({
write(data) { console.log(data) }
}))
await proc.exitFeatures
- ✅ Full Node.js runtime in the browser
- ✅
npm install— fetches packages from CDN - ✅ Virtual filesystem (
fs,fs/promises) - ✅ Spawn processes (
node,npm,npx,vite,next dev, ...) - ✅ HTTP server → Service Worker iframe preview
- ✅ WebSocket support (
ws) - ✅ 43+ built-in Node.js modules
- ✅ API-compatible with
@webcontainer/api(StackBlitz)
Supported Frameworks
React, Vue 3, Svelte, SolidJS, Preact, Angular, Next.js, Nuxt, Remix, Vite, Express, Fastify, Three.js, D3 and more.
Migrate from StackBlitz
npm uninstall @webcontainer/api
npm install @nodebeey/webcontainer- import { WebContainer } from '@webcontainer/api'
+ import { WebContainer } from '@nodebeey/webcontainer'
- const container = await WebContainer.boot()
+ const container = await WebContainer.boot({ apiKey: 'nbee_live_...' })
// Everything else is identical ✓Required Headers
Your page must be served with these headers (required for SharedArrayBuffer):
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-originAPI
WebContainer.boot(options)
| Option | Type | Description |
|--------|------|-------------|
| apiKey | string | Your Nodebeey API key (get one at nodebeey.com) |
| workdirName | string | Working directory name (default: "webcontainer") |
container.mount(fileTree)
Mount a virtual filesystem tree.
container.spawn(command, args?, options?)
Run a command. Returns { output, input, exit, kill }.
container.fs
readFile, writeFile, readdir, mkdir, rm, watch — mirrors fs/promises.
container.on(event, handler)
Events: server-ready, port, error.
container.teardown()
Destroy the container and free resources.
Pricing
| Plan | Hours/month | Keys | Price | |------|-------------|------|-------| | Free | 1,000 | 1 | $0 | | Starter | 10,000 | 5 | $29/mo | | Pro | 100,000 | Unlimited | $99/mo | | Enterprise | Unlimited | Unlimited | Custom |
Links
License
MIT © Nodebeey
