LiveTerminal
An interactive shell for live demos, with optional setup commands.
The dev server runs a local pseudo-terminal (PTY) through node-pty. xterm.js renders the terminal. A WebSocket carries input, output, and resize events.
Enable the terminal server
Commands run on the server’s machine with the permissions of the user running StageRoutine.
Add --terminal to the dev command in package.json to start the terminal server with your presentation:
{
"scripts": {
"dev": "stageroutine dev --terminal"
}
}
The server accepts local connections only.
Add a terminal
import { LiveTerminal } from "stageroutine";
const demo = LiveTerminal({
position: "center",
width: 120,
rows: 6,
title: "Live demo",
cwd: ".",
command: "export DEMO_MODE=1",
restartButton: true,
transcript: ["$ export DEMO_MODE=1", "$ pnpm test", "Tests: 42 passed"],
});
cwd selects a folder inside the project (default: project root). command runs before a new shell opens (default: none). Folder changes and exported variables carry into the shell.
rows sets the height in text rows. If omitted, the terminal fits height (default: 44 stage units).
Session behavior
Sessions persist across scene changes and page reloads. Setup runs only for a new session or an explicit restart.
restartButton: true adds a header button (default: false). It stops the shell, clears the screen, and runs setup again. demo.restart() does the same.
autoFocus: true focuses the terminal on scene entry (default: false). interactive: false disables typing (default: true). Click outside the terminal to return keyboard control to the presentation.
Sessions stop with the dev server, or after 2 minutes without a connected page by default.
Fallback transcript
transcript is text shown when a live session cannot start: the terminal server is disabled or cannot be reached. Default: [].
See the LiveTerminal API reference for all options and controls.