Building a Node js runtime for the browser
summary
Codesandbox builds a Node.js–compatible runtime that actually runs in the browser by using web workers to emulate processes, loading parts like the transpiler, crypto and compression as WebAssembly modules, and implementing a custom Node‑compatible file system with the main thread as source of truth to provide synchronous file operations (claimed faster than Node). HTTP and websockets use an iframe preview relay plus a service worker; websockets send raw packets into the worker where a client and server are spawned and parsed, and the system runs real Node apps including Next and Vite.
AI-written summary · about
chapters (6)
- 0:00Start
- 0:37npm modules to the rescue
- 2:37File System
- 3:30HTTP & Websockets → Service worker
- 5:53Got a basic server running
- 6:11Try it@nodebox.codesandbox.io
related talks
39m"Spinning up Node in the Browser"
40mIt's Not Just Node.js Anymore
25mNext-Gen Server JavaScript: Web Standards
27mWebAssembly and Node.js
46mUsing Node.js in the Browser with WebContainers
31mThe CPU in your browser: WebAssembly demystified
49mBun, Deno, Node.js? Recreating a JavaScript runtime from Scratch
23mWeb Assembly: The Future Of Js And A Multi-Language Web
