Interactive prompts
for Node.js CLIs
Five keyboard-driven prompts, graceful cancellation, structured logging, and session framing. Zero dependencies. Node.js 16+.
❯ npx prim-cliIntroduction
prim-cli is a zero-dependency library of interactive terminal prompts for Node.js. Every prompt is pure keyboard — arrow keys, space, enter, escape — rendered with ANSI truecolor escape codes directly to stdout.
No React. No DOM. No browser. Install it, await a prompt, get a value back.
Installation
Zero dependencies. Works with Node.js 16+.
npm❯ npm install prim-clipnpm❯ pnpm add prim-cliyarn❯ yarn add prim-cliQuick Start
Try the full interactive demo without installing anything:
Or wire all five prompts together — with graceful Ctrl+C handling:
select()
Single-choice selection. Arrow keys or j/k navigate, Enter confirms, Escape cancels. Returns a Promise<string>.
confirm()
Yes/no confirmation. Left/right arrows or y/n to toggle, Enter to confirm. Returns a Promise<boolean>.
input()
Free text input with live validation, placeholder text, and password masking. Returns a Promise<string>.
multiselect()
Multi-choice selection. Arrow keys navigate, Space toggles, Enter confirms. Returns a Promise<string[]>.
spinner()
Animated spinner with update, success, and error states. Returns a controller — not a Promise. Use it to wrap async work.
ANSI Utilities
Truecolor styling, cursor control, and named color constants — built in to prim-cli, zero extra deps.
isCancel() + cancel()
Every prompt resolves with the CANCEL symbol when the user presses Ctrl+C or Escape. Check with isCancel() — never === — and call cancel() to print a styled exit message.
intro() + outro()
Frame your CLI with a banner at the start and a closing message at the end. Automatically adapts to terminal width.
note()
Print a titled info box — great for summaries, next steps, or any multi-line structured output.
log.*
Structured log lines with consistent icon prefixes. Use these instead of console.log to keep your CLI output visually consistent.