Termkit
Build terminal experiences.
Termkit pairs a React terminal with persistent shell sessions. A terminal is a view onto a session: unmounting it leaves the shell running, and mounting the same session again reattaches to its current screen.
The workspace contains a React library, browser-safe protocol, native PTY daemon and optional tRPC adapter. These packages are private while their public APIs are being designed.
Connect a terminal
Mount a TermkitProvider near your app root with a stable configuration. Its connection URL points to your host's WebSocket route; its transport forwards session controls to your backend. Render Terminal inside a container with a defined height.
import { Terminal, TermkitProvider } from "@mp-lb/termkit";
<TermkitProvider config={config}>
<div style={{ height: 400 }}>
<Terminal session="workspace" autoFocus />
</div>
</TermkitProvider>The host owns routing and access control. Proxy the daemon through your application; the daemon binds to loopback by default. Session metadata can drive the daemon's working-directory resolver.
When the host has no UTF-8 locale, the daemon supplies one for character handling. Explicit daemon environment overrides take precedence.
Manage sessions
The provider polls the live registry independently of mounted terminals. Use session hooks to show background sessions, connection status and attention bells, and the actions hook to focus, kill or mark sessions seen. Queue a command before first attach to run it once after the shell prompt settles.
For tabbed interfaces that keep terminals mounted, update visible when a pane becomes active so its geometry and screen refresh. Wrapper backgrounds and terminal color schemes can be configured per terminal or through provider defaults.
The default font stack includes IBM Plex Mono and Noto Sans Symbols 2. Hosts may supply another font family in their terminal options.