KilnVM Docs

Embed live Linux sandboxes in any docs site.

Add one script tag and a single <div data-kilnvm-project="..."> wherever you want readers to run commands. KilnVM detects SPA route transitions automatically, locks embeds to your allowlisted domains, and tracks per-page launch counts in your dashboard without logging terminal output.

Quickstart

Create a project in the Dashboard, add your docs origin (for example https://docs.yourapp.com or http://localhost:3000), and paste this two-line embed anywhere in your quickstart page:

HTML / MDX Snippet
<div data-kilnvm-project="proj_your_project_id" data-kilnvm-cmd="mycli --help"></div>
<script src="https://kilnvm.dev/kilnvm-embed.js" defer></script>
Click-to-Run by default on customer docs

On external documentation domains, projects default to Click-to-Run (Launch Terminal overlay) so casual page scrolls never consume your monthly session quota. Pass data-kilnvm-autoboot="true" if you want a flagship quickstart box to boot immediately.

Framework Guides

Choose your documentation platform below. Because customer pages mount inside an origin-locked KilnVM iframe, CSP headers on your docs site only need to allow framing https://kilnvm.dev and loading https://kilnvm.dev/kilnvm-embed.js.

Use the MDX-safe <iframe> below directly in any Mintlify .mdx file (no external script needed). Wrap the iframe in Mintlify's <Frame> component to keep it constrained to the text column, and use JSX object syntax (style={{ ... }}) rather than an HTML string so .mdx compiles cleanly.

quickstart.mdx (Mintlify MDX-safe iframe)
<Frame>
  <iframe
    src="https://kilnvm.dev/embed?project=proj_your_project_id&cmd=mycli%20--help"
    title="KilnVM Interactive Sandbox"
    style={{ width: "100%", height: "420px", border: 0 }}
    allow="clipboard-read; clipboard-write"
    referrerPolicy="origin"
    loading="lazy"
  />
</Frame>
Optional: kilnvm-loader.js + <div data-kilnvm-project /> (for multi-file seeding & JS runCommand)
// Place kilnvm-loader.js at your Mintlify repo root
(function () {
  if (document.querySelector('script[src="https://kilnvm.dev/kilnvm-embed.js"]')) return;
  var s = document.createElement("script");
  s.src = "https://kilnvm.dev/kilnvm-embed.js";
  s.defer = true;
  document.head.appendChild(s);
})();

Per-Page Startup Commands

Set an account-wide fallback command in the Dashboard (Default Startup Command) or override it per tutorial page with data-kilnvm-cmd. On pages with multiple sandboxes, give each embed a unique data-kilnvm-id="..." and target it explicitly via window.KilnVMEmbed.runCommand(cmd, id).

Interactive "Try Step" Button Example
<div data-kilnvm-project="proj_your_project_id" data-kilnvm-id="step-2"></div>
<button onclick="window.KilnVMEmbed && window.KilnVMEmbed.runCommand('mycli validate', 'step-2')">
  Run Step 2
</button>

Starter Workspace Files (Zero Docker Rebuilds)

One CLI container image can power dozens of tutorial pages by seeding sample SQL queries, YAML configs, or JSON fixtures directly from your embed snippet into /workspace before the shell opens.

  • Limits: Up to 5 starter files and 64 KiB total UTF-8 size per embed.
  • Path safety: Relative non-dotfile paths up to 3 segments deep (for example query.sql or fixtures/sample.json). Paths containing .., backslashes, leading /, null bytes, or dotfiles like .bashrc are rejected.
Multi-line file block inside <div data-kilnvm-project>
<div data-kilnvm-project="proj_your_project_id" data-kilnvm-cmd="cat schema.sql && cat seeds/data.json">
  <script type="text/plain" data-kilnvm-file="schema.sql">
CREATE TABLE events (id INTEGER, kind TEXT);
  </script>
  <script type="text/plain" data-kilnvm-file="seeds/data.json">
{"seeded": true}
  </script>
</div>

Attributes & JS API Reference

Attribute / Method Description Default / Limit
data-kilnvm-project Your project ID (proj_...) from the Dashboard. Required
data-kilnvm-cmd Single-line command executed right after shell attaches. Dashboard default · max 256 chars
data-kilnvm-file + data-kilnvm-file-content Seed a single file into /workspace/<path> on boot. Relative path, no dotfiles
data-kilnvm-files JSON object mapping up to 5 relative paths to UTF-8 strings. Max 5 files · 64 KiB total
<script type="text/plain" data-kilnvm-file="..."> Ergonomic child block inside the mount element for multi-line starter files. Max 5 files · 64 KiB total
data-kilnvm-autoboot Set "true" to boot on load or "false" for Click-to-Run. "false" on customer docs
data-kilnvm-id Optional identifier used to target a specific embed on multi-sandbox pages. First sandbox if omitted
window.KilnVMEmbed.runCommand(cmd, target?) Sends a command to a specific data-kilnvm-id, project ID, CSS selector, or the first sandbox. Cross-origin safe via postMessage
window.KilnVMDemo.runCommand(cmd, target?) Backward-compatible alias for triggering commands from inline tutorial buttons. Cross-origin safe via postMessage
window.KilnVMEmbed.mountAll() Manually scans for unmounted [data-kilnvm-project] elements. Also runs via MutationObserver

Custom Docker Images

In your Dashboard under Custom Container Environments, queue either a public registry tag (for example ghcr.io/your-org/your-cli:1.4.0) or paste a custom Dockerfile (up to 16 KiB). KilnVM compiles a linux/amd64 microVM layer automatically and wires it to your project.

  • Include standard tooling or your binary on PATH; KilnVM sets up /workspace owned by UID 1000 and invokes /bin/bash (falling back to /bin/sh on Alpine images).
  • Automate sandbox updates on every release in GitHub Actions with a Bearer kvm_live_... API key from your Dashboard:
GitHub Release Webhook / cURL Rebuild
curl -fsSL -X POST https://api.kilnvm.dev/api/projects/proj_your_project_id/image-request \
  -H "Authorization: Bearer $KILNVM_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"sourceType\":\"public_image\",\"sourceValue\":\"ghcr.io/your-org/your-cli:${GITHUB_REF_NAME}\"}"

Scale Egress Allowlist & Webhooks

By default, all outbound internet access from visitor containers is blocked. On the Scale plan, add exact hostnames (like api.yourapp.com) under your project settings to allow outbound HTTP/HTTPS on ports 80 and 443 only.

  • Wildcard domains, raw IP addresses, and internal hostnames are blocked automatically to prevent SSRF.
  • Scale accounts also receive HMAC-SHA256 signed webhook events (X-KilnVM-Signature: t=...,v1=...) when monthly usage crosses 80%, 100%, and 110%.