Introduction
Welcome to the Strapkit documentation.
Strapkit runs Node.js directly in the browser. You write normal Node code, and Strapkit gives you a filesystem, processes, and outbound networking — all on the page, no server required.
import Strapkit from "@strapkit/core";
const sk = new Strapkit({ apiKey: "sk_live_…" });
await sk.init();
// Write a file and run it
await sk.write("/app/index.js", `
const http = require("http");
http.createServer((req, res) => {
res.end("Hello from the browser");
}).listen(3000);
`);
sk.shellExec("node /app/index.js");
// Open a preview when the server starts
sk.onPortOpen((port) => {
if (port === 3000) sk.showPreview(port, "preview");
});What's here
- Getting Started — install Strapkit and run your first Node process in the browser.
- API Reference — every public method, grouped by what it
does:
- Strapkit class — construction,
init(), andsetApiKey(). - Filesystem — read, write, walk, and delete files.
- Processes — run Node processes or attach an interactive shell to a terminal in your page.
- Preview iframe — show a running HTTP server inside a sandboxed iframe.
- Cache — persist directory trees across page reloads.
- Errors — the two error classes Strapkit throws and how to handle them.
- Strapkit class — construction,
How it fits together
Under the hood, Strapkit loads a Node.js runtime compiled to WebAssembly, adapted to run in the browser environment. The runtime executes inside Web Workers so it doesn't block your UI thread, and workers communicate through SharedArrayBuffer — which is
why your page needs
cross-origin isolation headers.
Filesystem. Files live in an in-memory filesystem. Anything you
write with sk.write() is immediately visible
to processes you spawn, and anything those processes create is readable
with sk.read(). The filesystem is wiped on page reload — use the
Cache API to persist trees across sessions.
Processes. sk.exec() runs a shell script and captures its output.
For interactive use, pass an xterm.js terminal to the
constructor and use sk.shellExec() to type commands into a live shell.
Both approaches share the same filesystem.
Networking. TCP and UDP connections made inside Node are routed through a WebSocket-based network proxy, so code running in the browser can talk to the real internet. Your API key authenticates the connection automatically.
Preview. When a process starts an HTTP server, Strapkit can display
it in a sandboxed iframe on your page via
showPreview(). The
onPortOpen
callback tells you the moment a port binds, so you can wire it up
without polling or log scraping.