Migration from Ink
BetterTUI is API-compatible with Ink. Migration is straightforward.
Install
Section titled “Install”# Remove Inkpnpm remove ink react-reconciler
# Add BetterTUIpnpm add @bettertui/reactReplace Imports
Section titled “Replace Imports”// Before (Ink)import { Box, Text, useInput } from 'ink';
// After (BetterTUI)import { Box, Text, useInput } from '@bettertui/react';API Differences
Section titled “API Differences”Render
Section titled “Render”// Inkimport { render } from 'ink';render(<App />);
// BetterTUIimport { render } from '@bettertui/react';render(<App />);useInput
Section titled “useInput”// InkuseInput((input, key) => { if (key.return) { /* ... */ }});
// BetterTUI (same API)useInput((input, key) => { if (key.return) { /* ... */ }});useApp
Section titled “useApp”// Inkimport { useApp } from 'ink';const { exit, isRawModeSupported } = useApp();
// BetterTUIimport { useApp } from '@bettertui/react';const { exit, isRawModeSupported } = useApp();What’s New
Section titled “What’s New”BetterTUI adds features not available in Ink:
- Flexbox layout via Taffy (CSS Flexbox, not custom DSL)
- Rust rendering engine (60fps, dirty rect diffing)
- Rich widget library (Table, Tree, Dialog)
- Animation engine (tweens, keyframes)
- Theme system (CSS variables, dark mode)
- Mouse support (click, scroll, drag)
- Clipboard integration (copy/paste)
Breaking Changes
Section titled “Breaking Changes”None. BetterTUI is designed as a drop-in replacement for Ink.
Performance
Section titled “Performance”Expect significant performance improvements:
- Rendering: Native Rust vs JavaScript
- Layout: Taffy flexbox vs custom implementation
- Memory: ~60% reduction in typical apps
- Startup: ~40% faster cold start