---
title: "Introduction"
description: "Terminal apps, written in TypeScript and compiled to native executables with scriptc."
canonical_url: "https://tui-sdk.dev/docs"
---
# Introduction

tui is a TypeScript library for terminal apps. You write the app once: it runs on Node.js 24 or later while you work on it, and [scriptc](https://www.npmjs.com/package/scriptc) compiles the same file to one native executable that starts in 2 ms, with less memory and a smaller binary than Node.js. Everything below is running in your browser, from the files in the repository's `examples` directory.

The HTML page runs these examples here, in a terminal in the page:

- [Dashboard: `examples/dashboard.ts`](https://github.com/vercel-labs/tui/blob/main/examples/dashboard.ts)
- [Earth: `examples/earth.ts`](https://github.com/vercel-labs/tui/blob/main/examples/earth.ts)
- [3D: `examples/maze.ts`](https://github.com/vercel-labs/tui/blob/main/examples/maze.ts)
- [Fluid: `examples/fluid.ts`](https://github.com/vercel-labs/tui/blob/main/examples/fluid.ts)
- [Chat: `examples/assistant.ts`](https://github.com/vercel-labs/tui/blob/main/examples/assistant.ts)
- [Logs: `examples/logs.ts`](https://github.com/vercel-labs/tui/blob/main/examples/logs.ts)

## How an app works

An app is a view: a function that draws the whole screen from your state. tui calls it for each frame that changed, routes keys and clicks to the part that has the focus, and writes only the cells that moved.

```ts
import { runApp, text } from "tui"

let count = 0

runApp({
  view: (frame) => {
    text(frame, 1, 1, `Count: ${count}`, frame.theme.heading)
    text(frame, 1, 2, "Press + or - to change it. Ctrl+C quits.", frame.theme.muted)
  },
  keys: (key) => {
    if (key.name !== "char") {
      return false
    }
    if (key.text === "+") {
      count++
      return true
    }
    if (key.text === "-") {
      count--
      return true
    }
    return false
  },
})
```


## Compiled to native

The file above runs with `node counter.ts`. `npx scriptc build counter.ts -o counter` turns it into one executable with no runtime to install, and the same terminal behavior.

| | Native, with scriptc | Node.js 24 |
| --- | --- | --- |
| Start to first frame | 1.7 ms | 94 ms |
| Peak memory | 3.6 MB | 101 MB |
| Size of what runs | 1.7 MB | 123 MB |

See [Performance](/docs/guides/performance) for how these are measured.

## Built for agents

Agents write most new code, check it, and use the software too. tui is built for all three:

- **Writing it.** Every page of these docs is also Markdown: add `.md` to its address, or start from [llms.txt](/llms.txt). `scriptc coverage` names each line that won't compile to native code, and why.
- **Checking it.** `createTestApp` runs an app with no terminal. A test presses keys, clicks, and reads the screen back as text. See [Testing](/docs/guides/testing).
- **Using it.** One line makes an app an MCP server: an agent lists every component on screen, with its state, and acts on it by name. See [Agents](/docs/guides/agents).

> tui is experimental. Its API will change before 1.0.

## What's in it

- [Components](/docs/concepts/components): Listbox, CheckboxGroup, Tabs, Table, Input, Textarea, Dialog, and ScrollArea, drawn every frame from your state.
- [Shaders and images](/docs/guides/graphics): A color for every pixel, two to a cell, and images in kitty, Ghostty, and half blocks.
- [Motion](/docs/guides/motion): Springs, transitions, and easings that move a number over the next frames.
- [Long lists](/docs/guides/long-lists): A million lines, filtered as you type a few milliseconds a frame.
- [Games](/docs/guides/games): Sprites, tilemaps, a camera, collision, and a fixed step.
- [Prompts](/docs/guides/prompts): Text, select, confirm, spinner, and progress below the cursor.
- [Keys and mouse](/docs/concepts/input): Modifiers, the kitty keyboard protocol, whole pastes, clicks, and the wheel.
- [Unicode](/docs/reference/text): Unicode 17 widths for wide characters, emoji sequences, flags, and combining marks.

## Next steps

- [Install tui](/docs/installation): One package, no runtime dependencies.
- [Build your first app](/docs/quick-start): Build a chat from components, then build it and test it.
- [Read the rendering model](/docs/concepts/rendering-model): How a frame is drawn, and what reaches the terminal.
- [Look up an export](/docs/reference/app): Every export, with its options.
