Embed a live Linux CLI terminal in VitePress
VitePress compiles Vue-enhanced Markdown where standard HTML containers and script tags render cleanly. Register kilnvm-embed.js once in .vitepress/config.mts and drop interactive microVMs into any guide.
1. Add KilnVM to VitePress
.vitepress/config.mts
import { defineConfig } from "vitepress";
export default defineConfig({
head: [
["script", { src: "https://kilnvm.dev/kilnvm-embed.js", defer: "" }],
],
});
2. Seed Files, Run Buttons & Production Tips
docs/guide/getting-started.md (inline starter files)
<div
data-kilnvm-project="proj_your_project_id"
data-kilnvm-theme="auto"
data-kilnvm-cmd="mycli validate pipeline.yaml"
>
<script type="text/plain" data-kilnvm-file="pipeline.yaml">
name: ci-check
steps:
- lint
- test
</script>
</div>
- VitePress supports standard HTML <script type="text/plain" data-kilnvm-file="..."> child blocks inside Markdown without escaping.
- For zero script changes or teams locking down CSP, use a standard <iframe> pointing to https://kilnvm.dev/embed.
- Add clickable <button data-kilnvm-run="..."> walkthrough steps alongside static code blocks for faster reader activation.
3. Try a Live Sandbox Right Now
Click Launch Terminal below to boot a real non-root Linux microVM directly in the page.
Frequently Asked Questions
Does VitePress SPA navigation keep or remount KilnVM terminals?
Navigating to a new page with a mount div automatically initializes the new container via kilnvm-embed.js MutationObserver.
Can I pass custom VitePress palette colors?
Yes. Set data-kilnvm-accent, data-kilnvm-bg, data-kilnvm-surface, data-kilnvm-fg, and data-kilnvm-border to match your Vue theme CSS variables.
Ready in 5 minutes
Ship live CLI sandboxes inside your docs.
Start free with 300 sessions per month, isolated linux/amd64 microVMs, and zero credit card required.