AstroVHS
AstroVHS records VHS tapes into videos embedded in your Astro pages:
import VHSTape from '@atuin.sh/astro-vhs/VHSTape.astro'
<VHSTape alt="Greeting from a shell"> Type "echo 'Hello from VHS'" Sleep 500ms Enter Sleep 2s</VHSTape>The site needs @astrojs/mdx
(Starlight includes it) and the unified processor from
@astrojs/markdown-remark. Of course,
VHS also needs to be installed on your computer.
Configure your astro.config.mjs as follows:
import { unified } from '@astrojs/markdown-remark'import vhs from '@atuin.sh/astro-vhs'import { defineConfig } from 'astro/config'
export default defineConfig({ markdown: { processor: unified() }, integrations: [ vhs({ theme: { light: 'Catppuccin Latte', dark: 'Catppuccin Mocha' }, settings: { FontSize: 28, Width: 1200, Height: 400 }, }), ],})Writing tapes
Section titled “Writing tapes”Simply inline your VHS tapes in your code:
<VHSTape alt="Counting to three" caption="A tape over several lines."> Type "seq 3" Sleep 500ms Enter Sleep 2s</VHSTape>Rendering takes time, please be patient! AstroVHS will cache and memorize your tapes, so that they only get re-rendered in-case something changes.
Options
Section titled “Options”AstroVHS is relatively customizable, and the main customization point is the VHSTape component.
Some props you might be interested in tweaking are:
| Prop | Description | Example |
|---|---|---|
alt |
Alternate Text | Image showing how to use Atuin |
caption? |
Caption, always visible under the recording | Atuin Usage |
tape? |
The content of the tape, if not provided as a child. | Type "seq 3" Sleep 500ms Enter |
Global Settings
Section titled “Global Settings”Additionally, you can customize AstroVHS with global settings in the vhs integration plugin:
export default defineConfig({ markdown: { processor: unified() }, integrations: [ vhs({ theme: { light: 'Catppuccin Latte', dark: 'Catppuccin Mocha' }, settings: { FontSize: 28, Width: 1200, Height: 400 }, }), ],})Some useful settings are:
| Setting | Description | Example |
|---|---|---|
settings? |
Any VHS Set commands you want to prepend, before recording starts. |
settings: { FontSize: 28, TypingSpeed: '50ms' } |
theme? |
Either a VHS-supported theme, or a fully customized theme. |
theme: { light: 'Catppuccin Latte', dark: 'Catppuccin Mocha' } |
setup? |
VHS commands you want to run before recording starts. | setup: 'Type "cd $VHS_SCRATCH && clear"\nEnter' |
teardown? |
VHS commands you want to run after recording ends. | teardown: 'Type "kill %1"\nEnter' |
env? |
Any environment variables you want to set. | env: { NO_COLOR: '1' } |
formats? |
Which formats you want to record to. | formats: ['webm'] |
cacheKey? |
A function invoked for each tape to compute the content hash. | cacheKey: ({ defaultKey }) => `${defaultKey}:v2` |
concurrency? |
How many recordings run at once; a quarter of your cores by default. Use 1 if tapes share a port, socket or file outside $VHS_SCRATCH. |
concurrency: 2 |
Theming
Section titled “Theming”In theme, you can pass any of the themes in
vhs/themes.json by name, or you can
provide a custom theme, which adheres to VhsThemeColors.
Caching
Section titled “Caching”By default, AstroVHS caches your tapes based on the props passed to <VHSTape />. This means that
if a tape relies on an external command or an external file (think .bashrc or the like), then
AstroVHS will re-use the old version.
You can customize his behavior by tweaking the cache key function. For example, you can make it
read the mtime of your .bashrc:
import { stat } from 'node:fs/promises'
vhs({ cacheKey: async ({ defaultKey }) => { const { mtimeMs } = await stat(new URL('vhs/.bashrc', import.meta.url)) return `${defaultKey}:${mtimeMs}` },})