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:
<div data-kilnvm-project="proj_your_project_id" data-kilnvm-cmd="mycli --help"></div>
<script src="https://kilnvm.dev/kilnvm-embed.js" defer></script>
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.
<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>
// 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);
})();
Drop the MDX-safe JSX <iframe> straight into any .mdx tutorial page with style={{ width: "100%", height: "420px", border: 0 }}, or register https://kilnvm.dev/kilnvm-embed.js globally in docusaurus.config.js when using multi-file <div> mounts.
<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, borderRadius: "10px" }}
allow="clipboard-read; clipboard-write"
referrerPolicy="origin"
loading="lazy"
/>
export default {
scripts: [
{
src: "https://kilnvm.dev/kilnvm-embed.js",
defer: true,
},
],
};
For Nextra, Fumadocs, or Next.js App Router MDX pages, use JSX object styles (style={{ width: "100%", height: "420px", border: 0 }}) on <iframe>, or add next/script once in app/layout.tsx to pass multi-file starter objects via JSON.stringify.
<iframe
src="https://kilnvm.dev/embed?project=proj_your_project_id&cmd=ls%20-la"
title="KilnVM Interactive Sandbox"
style={{ width: "100%", height: "420px", border: 0, borderRadius: "10px" }}
allow="clipboard-read; clipboard-write"
referrerPolicy="origin"
loading="lazy"
/>
import Script from "next/script";
// Once in app/layout.tsx:
<Script src="https://kilnvm.dev/kilnvm-embed.js" strategy="afterInteractive" />
// In any TutorialPage.mdx:
<div
data-kilnvm-project="proj_your_project_id"
data-kilnvm-cmd="ls -la && cat query.sql"
data-kilnvm-files={JSON.stringify({
"query.sql": "SELECT 42 AS answer;\n",
"data/users.csv": "id,plan\n1,pro\n2,scale\n",
})}
/>
Add the deferred script tag to .vitepress/config.mts and write standard HTML or inline <script type="text/plain" data-kilnvm-file="..."> blocks inside your Markdown files.
import { defineConfig } from "vitepress";
export default defineConfig({
head: [
["script", { src: "https://kilnvm.dev/kilnvm-embed.js", defer: "" }],
],
});
Works with zero build step on static HTML, MkDocs, Hugo, or Ghost. Pair optional buttons with window.KilnVMDemo.runCommand(...) so readers can trigger tutorial steps right from prose.
<div
data-kilnvm-project="proj_your_project_id"
data-kilnvm-cmd="mycli check config.yaml"
>
<script type="text/plain" data-kilnvm-file="config.yaml">
name: quickstart-demo
mode: strict
</script>
</div>
<script src="https://kilnvm.dev/kilnvm-embed.js" defer></script>
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).
<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
5starter files and64 KiBtotal UTF-8 size per embed. - Path safety: Relative non-dotfile paths up to 3 segments deep (for example
query.sqlorfixtures/sample.json). Paths containing.., backslashes, leading/, null bytes, or dotfiles like.bashrcare rejected.
<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/workspaceowned by UID1000and invokes/bin/bash(falling back to/bin/shon Alpine images). - Automate sandbox updates on every release in GitHub Actions with a Bearer
kvm_live_...API key from your Dashboard:
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 crosses80%,100%, and110%.