Quickstart - Secure Exec
Kernel API
For multi-process workloads (shell commands, child processes, inter-process communication), use the kernel API. This requires both a Node.js runtime and a shell runtime (WasmVM).
import {
createKernel,
createInMemoryFileSystem,
createNodeRuntime,
} from "secure-exec";
const kernel = createKernel({
filesystem: createInMemoryFileSystem(),
});
await kernel.mount(createNodeRuntime());
// spawn() runs a command directly (no shell needed)
const proc = kernel.spawn("node", ["-e", "console.log('hello')"], {
onStdout: (data) => process.stdout.write(data),
});
await proc.wait();
await kernel.dispose();