Skip to content

Adapters Overview

@termuijs/adapters is the integration layer between TermUI apps and the outside world. Each adapter wraps a third-party library or system API and exposes a consistent, typed interface your app calls directly.

Adapters follow a hook-style naming convention (useX) and lazy-load optional peer dependencies at runtime. Your app only pays for what it imports.

Installation

·CODE
npm install @termuijs/adapters

Most adapters also require an optional peer dependency. Install only the ones you need:

·CODE
# AI
npm install openai                # for OpenAI provider
npm install @anthropic-ai/sdk    # for Anthropic provider

# CLI tools
npm install chalk
npm install execa
npm install simple-git

# Integrations
npm install @octokit/rest        # GitHub
npm install keytar               # system keychain
npm install zod                  # schema validation
npm install dotenv               # .env file loading
npm install conf                 # persistent config

Adapters

AdapterExportDescription
Local StorageuseLocalStorageKey-value store backed by a JSON file in ~/.config/termui/
ConfuseConfTyped persistent config using the conf library
AIuseAISingle interface for OpenAI and Anthropic chat and embeddings
Vector StoreLocalVectorStoreIn-process vector store for embedding-based similarity search
ChalkchalkToTermUIPasses chalk-styled strings through and strips ANSI when NO_COLOR is set
ExecauseExecaRuns subprocesses and streams output line by line
GituseGitStatus, log, stage, commit, push, pull, diff via simple-git
GitHubuseGitHubLists repos, issues, PRs, and releases via @octokit/rest
KeychainuseKeychainReads and writes secrets from the OS keychain via keytar
ZodzodValidatorConverts a Zod schema into a TermUI prompt validator function
DotenvuseDotenvParses .env files and exposes values as a typed record

Quick example

Read a value from local storage and display it in a Text widget:

·CODE
import { App } from '@termuijs/core'
import { Text } from '@termuijs/widgets'
import { useLocalStorage } from '@termuijs/adapters'

const store = useLocalStorage('my-app')
store.set('username', 'alice')

const username = store.get<string>('username') ?? 'guest'
const label = new Text(`Hello, ${username}`, { fg: 'cyan', bold: true })

const app = new App(label, { fullscreen: false })
await app.mount()

Pages in this section