almostnode — Node.js in your browser

2 min read Original article ↗
What is almostnode for?

Running demos and playgrounds of Node.js projects directly in the browser — no backend server needed. Think interactive documentation, code tutorials, and live examples that work from a static HTML page.

Can I use this for AI coding agents?

Yes. An AI agent can write code, execute it via almostnode, inspect output, and iterate — all client-side. No sandbox server to provision or manage. For untrusted AI-generated code, run it in a sandboxed cross-origin iframe.

Is this production-ready?

No. almostnode is experimental. It covers common Node.js APIs but not all edge cases. Expect bugs, especially with complex npm packages that rely on native modules or Node.js internals. Please file issues on GitHub.

How should I handle security?

Always run untrusted code in a cross-origin sandboxed iframe (sandbox="allow-scripts"). almostnode supports both same-origin and cross-origin modes via the service worker bridge. See the Security docs for setup details.

How does this differ from WebContainers?

almostnode is ~250KB gzipped (vs ~2MB), starts instantly (vs 2-5s), and runs on the main thread or a Web Worker. WebContainers provide a full Linux kernel with real TCP/IP and native module support. almostnode is better for lightweight playgrounds and demos; WebContainers for full dev environments.

What Node.js modules are supported?

40+ shimmed modules including fs, path, http, crypto, stream, buffer, events, url, zlib, and more. These are browser-compatible implementations — not the full Node.js API, but enough for most web frameworks and npm packages. See the API Reference.

Does it work offline?

The runtime works offline once loaded. However, npm.install() fetches packages from the npm registry, so it requires an internet connection. You can pre-populate the virtual filesystem with package files for offline use.