Termkit

<Terminal> & provider

The component and provider reference for @mp-lb/termkit.

TermkitProvider

Mount once near your app root. It creates the session registry, starts the poller, and provides config to everything below.

<TermkitProvider config={config}>{children}</TermkitProvider>

TermkitConfig

FieldTypeNotes
connectionUrl({ sessionId, params }) => stringBuilds the WebSocket URL for a session. params is the opaque metadata bag forwarded to the daemon.
transport{ list, kill, seen }Control plane. list(): Promise<LiveSession[]>, kill(id), seen(id).
pollIntervalMs?numberHow often to poll the live list. Default 2000.
terminalOptions?TermkitTerminalOptionsVisual defaults (see below).

Treat config as stable — define it outside render or memoise it. The store and poller are created from the config captured on first render.

TermkitTerminalOptions

FieldTypeDefault
fontFamilystring"IBM Plex Mono", monospace
fontSizenumber13
cursorBlinkbooleantrue
backgroundstringfalls back to CSS var --termkit-bg, then --background, then #0a0a0a

Terminal

<Terminal session="global" autoFocus />
<Terminal session={tab.id} params={{ slug: 'myproject' }} />
PropTypeDefaultNotes
sessionstringRequired. Stable session id; doubles as the daemon session id, so re-rendering it reattaches.
paramsRecord<string, string>{}Opaque metadata forwarded to the daemon on connect. Read only on first attach.
autoFocusbooleanfalseTake keyboard focus on mount.
dismissOnViewbooleantrueClear this session's bell when viewed (attach / focus / bell-while-focused).
pendingCommandstringA command auto-typed once, after the prompt settles on first attach.
onExitFocus() => voidCalled on the Ctrl+Shift+Enter exit chord, after termkit blurs the terminal. Use it to move DOM focus in your UI.
classNamestring
styleCSSPropertiesMerged over { width: '100%', height: '100%' }.

Sizing

The terminal fills its container (100% width and height) and refits on resize via a ResizeObserver. Give it a sized parent.

Focus and the exit chord

autoFocus and the focus/blur actions drive xterm focus through the registry. Inside a focused terminal, Ctrl+Shift+Enter releases focus and calls onExitFocus — handle it to land DOM focus somewhere sensible (a tab, a sidebar item) so your keyboard shortcuts work again.

Auto-typing a command

pendingCommand (or setPendingCommand(id, cmd) before mount) queues a command that runs exactly once, on the session's first attach, after the shell's prompt has finished painting. It is not persisted, so a reload never re-runs it — the daemon already has the shell with whatever's running in it.

On this page