<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
| Field | Type | Notes |
|---|---|---|
connectionUrl | ({ sessionId, params }) => string | Builds 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? | number | How often to poll the live list. Default 2000. |
terminalOptions? | TermkitTerminalOptions | Visual 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
| Field | Type | Default |
|---|---|---|
fontFamily | string | "IBM Plex Mono", monospace |
fontSize | number | 13 |
cursorBlink | boolean | true |
background | string | falls back to CSS var --termkit-bg, then --background, then #0a0a0a |
Terminal
<Terminal session="global" autoFocus />
<Terminal session={tab.id} params={{ slug: 'myproject' }} />| Prop | Type | Default | Notes |
|---|---|---|---|
session | string | — | Required. Stable session id; doubles as the daemon session id, so re-rendering it reattaches. |
params | Record<string, string> | {} | Opaque metadata forwarded to the daemon on connect. Read only on first attach. |
autoFocus | boolean | false | Take keyboard focus on mount. |
dismissOnView | boolean | true | Clear this session's bell when viewed (attach / focus / bell-while-focused). |
pendingCommand | string | — | A command auto-typed once, after the prompt settles on first attach. |
onExitFocus | () => void | — | Called on the Ctrl+Shift+Enter exit chord, after termkit blurs the terminal. Use it to move DOM focus in your UI. |
className | string | — | |
style | CSSProperties | — | Merged 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.