The same
NodeRuntime class works in both Node.js and browser environments. The system driver and runtime driver factory determine where code actually runs — NodeRuntime is just the execution API.Basic setup
createBrowserDriver is async because it needs to initialize the Origin Private File System (OPFS) before returning.
Filesystem options
Choose between persistent OPFS storage or a transient in-memory filesystem.- OPFS (default) — backed by the browser’s Origin Private File System. Data persists across page reloads and browser restarts within the same origin. Falls back to in-memory if OPFS is unavailable.
- In-memory — ephemeral storage that is discarded when the page unloads.
Networking
Enable the browser fetch adapter to allow sandboxed code to make HTTP requests.Worker URL
Customize the worker script URL if you need to serve it from a specific path.Differences from Node driver
- Async creation:
createBrowserDriverreturns aPromise(OPFS initialization) - No child processes:
CommandExecutoris not available - No DNS: only fetch-based networking, no
dnsLookup - OPFS limitations: atomic rename and symlinks are not supported
- No resource limits:
memoryLimit,cpuTimeLimitMs, andtimingMitigationare not available in the browser runtime