API Reference

ink

React-based library for building interactive command-line interfaces using components, hooks, and flexbox layout.

Official Documentation ↗
CompatibilityThis documentation covers version v8.0.0. Check the official docs for the latest API surface.

Installation

npmnpm install ink react
pnpmpnpm add ink react

Methods

Overview

ink is a React-based library for building interactive command-line interfaces using components, hooks, and flexbox layout. This reference lists the most frequently used APIs with accurate signatures and runnable snippets.

Core APIs

  • render — Mounts a React tree to the terminal and returns an instance you can rerender or unmount.
  • Text — Renders styled text, the basic building block of an Ink interface.
  • useInput — Hook that subscribes to keyboard input for interactive controls.

Example

const React = require('react');
const { render, Text } = require('ink');

const App = () => React.createElement(Text, { color: 'green' }, 'Hello');
render(React.createElement(App));

Notes

JSX requires a build step, so plain React.createElement works without one. Key input is handled through the useInput hook.

Verification

Render a Text component to the terminal and confirm the message appears with the requested color.

Errors

The following points are quoted verbatim from the official documentation. 来源:https://cdn.jsdelivr.net/gh/vadimdemedes/ink@latest/readme.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:50:27.553Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

Security notes

Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://cdn.jsdelivr.net/gh/vadimdemedes/ink@latest/readme.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:50:27.553Z.

FAQ

How do I exit an Ink app?
Call the useApp hook to obtain exit(), or process.exit(0); the instance returned by render also has unmount().
Does Ink need a build step for JSX?
Yes for JSX syntax; without a compiler you can use React.createElement directly as shown here.
How do I test Ink components?
Use ink-testing-library to render into an in-memory stream and assert on the last frame output.