Skip to content

Terminal Recordings

Use the just command to start a recording:

Terminal window
just record-cast my-demo

This runs asciinema rec and saves the output to public/recordings/my-demo.cast. Run your commands in the terminal session, then press Ctrl+D or type exit to stop recording.

Import the wrapper component and use it as a JSX tag:

import AsciinemaPlayerWrapper from "../../../../../components/AsciinemaPlayerWrapper.astro";
<AsciinemaPlayerWrapper src="/recordings/my-demo.cast" />

The player loads no JavaScript until the user scrolls it into view, matching the lazy hydration pattern used by the chart and counter components.

All attributes beyond src are optional:

AttributeTypeDescription
srcStringPath to the .cast file (required)
colsNumberTerminal width in columns
rowsNumberTerminal height in rows
autoPlayBooleanStart playing automatically
loopBooleanLoop playback
speedNumberPlayback speed multiplier (e.g. 2 for double speed)
idleTimeLimitNumberCap idle time during playback (seconds)
themeStringColor theme (e.g. "dracula", "solarized-dark")
fitStringFit mode: "width", "height", "both", "none"
controlsStringShow player controls
posterStringText to show before playback starts
startAtNumberStart playback at this time (seconds)
preloadBooleanPreload the recording
terminalFontSizeStringTerminal font size (e.g. "15px")

Auto-playing at double speed:

<AsciinemaPlayerWrapper src="/recordings/my-demo.cast" autoPlay={true} speed={2} />

Looping with a theme:

<AsciinemaPlayerWrapper src="/recordings/my-demo.cast" loop={true} theme="dracula" />

Fixed dimensions:

<AsciinemaPlayerWrapper src="/recordings/my-demo.cast" cols={80} rows={24} fit="none" />

The implementation follows the same pattern as the other interactive components (counter, charts):

  1. AsciinemaPlayer.tsx — A Solid.js component that dynamically imports asciinema-player on mount and calls AsciinemaPlayer.create() on a ref div. Cleans up the player instance on unmount.
  2. AsciinemaPlayerWrapper.astro — An Astro wrapper that renders the Solid.js component with client:visible for progressive hydration.
  3. MDX import — Content authors import the Astro wrapper and use it as a component tag.

Cast files are plain text (JSON lines), so they’re small and version-control friendly.