Getting Started
Install Strapkit and run your first Node process in the browser.
Prerequisites
Before you start, make sure you have:
- An API key. Create one in your dashboard at
/dashboard/api-keys. - Cross-origin isolation headers on your page. The runtime uses
SharedArrayBuffer, which browsers only allow on cross-origin isolated pages. See Setup Headers for how to configure this for your host.
Install
npm install @strapkit/coreHello, world
import Strapkit from '@strapkit/core';
const sk = new Strapkit({ apiKey: 'sk_live_…' });
await sk.write('/hello.js', 'console.log("hi from the browser")');
const { stdout } = await sk.exec('node /hello.js');
console.log(stdout); // "hi from the browser\n"You don't have to call init() explicitly — every method waits for the
runtime to load on its own. Calling it first is just a way to preload
before the user interacts.
Add an interactive terminal
Pair Strapkit with xterm.js to give users a full shell in the browser:
import { Terminal } from '@xterm/xterm';
import { FitAddon } from '@xterm/addon-fit';
import '@xterm/xterm/css/xterm.css';
import Strapkit from '@strapkit/core';
const term = new Terminal({ cursorBlink: true, convertEol: true });
const fit = new FitAddon();
term.loadAddon(fit);
term.open(document.querySelector('#term'));
fit.fit();
const sk = new Strapkit({ apiKey: 'sk_live_…', terminal: term });
await sk.init();
// The user now has a working shell prompt.Preview an HTTP server
Start a server inside the runtime and show it in an iframe on your page:
sk.onPortOpen((port) => {
if (port === 3000) sk.showPreview(port, 'my-preview');
});
sk.shellExec('cd /app && npm run dev');The callback fires the moment the port binds — no polling, no log parsing.
What to read next
- Setup Headers — configure cross-origin isolation for your host.
- Setting up the terminal — full xterm.js integration walkthrough.
- Filesystem — recipes for reading, writing, and exporting files.
- API Reference — every public method.