npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@effect-tui/react

v2.0.1

Published

React bindings for @effect-tui/core

Readme

@effect-tui/react

React renderer for terminal UIs with spring animations.

Installation

bun add @effect-tui/react @effect-tui/core effect react

Quick Start

// tsconfig.json: { "compilerOptions": { "jsxImportSource": "@effect-tui/react" } }

import { render, useQuit, useShortcut } from "@effect-tui/react"

function App() {
  const [count, setCount] = useState(0)

  const quit = useQuit()
  useShortcut({
    q: () => quit(),
    space: () => setCount((c) => c + 1),
  })

  return (
    <vstack>
      <text>Count: {count}</text>
      <text fg="gray">Press space to increment, q to quit</text>
    </vstack>
  )
}

render(<App />)

Dev / HMR

Enable hot reload by passing dev: true and importMeta:

export default function App() { ... }

render(<App />, { dev: true, importMeta: import.meta })

Note: When dev: true, the entry module's default export is re-imported on each change. Keep your app as the default export for reliable HMR.

JSX Elements

  • <vstack> - Vertical flex layout
  • <hstack> - Horizontal flex layout
  • <text> - Text with optional fg/bg colors
  • <box> - Container with optional border
  • <canvas> - Imperative drawing API
  • <spacer> - Flexible space

Canvas draw context:

  • text(x, y, str, style?)
  • fillRect(x, y, w, h, char?, style?)
  • box(x, y, w, h, opts?)
  • clear()
  • style(style?) → style id for reuse
  • cell(x, y, cp, style?, width?)
  • cells(cells[])

Hooks

  • useKeyboard(callback) - Handle keyboard input
  • useShortcut(shortcuts, options?) - Map key strings to handlers
  • usePaste(callback) - Handle bracketed paste events (callback receives { text, preventDefault? })
  • useQuit() - Request a clean exit (restores terminal state)
  • useTerminalSize() - Get terminal dimensions (re-renders on resize)
  • useSpring(initial, options) - Spring animation
  • useSprings(count, fn) - Multiple springs
  • useColorSpring(color, options) - Animate colors

Components

  • TextInput - Single-line input (pasting inserts normalized text)
  • MultilineTextInput - Multi-line input (pasting preserves newlines)

Spring Animations

import { useSpring, useSpringRenderer, useRenderer } from "@effect-tui/react"

function AnimatedBox() {
  const renderer = useRenderer()
  useSpringRenderer(renderer)

  const [xMv, setX] = useSpring(0, { visualDuration: 0.35 })

  useKeyboard((key) => {
    if (key.name === "right") setX(20)
    if (key.name === "left") setX(0)
  })

  return (
    <canvas draw={(ctx) => {
      ctx.box(xMv.get(), 0, 10, 5, { border: "rounded" })
    }} />
  )
}

Architecture

Each frame (60fps default):

  1. Measure - Host tree calculates sizes bottom-up
  2. Layout - Host tree assigns positions top-down
  3. Render - Each host writes to CellBuffer
  4. Diff - Compare with previous buffer, find changed lines
  5. Write - Single stdout.write() with ANSI sequences
React JSX → Reconciler → Host Tree → CellBuffer → Terminal

Testing

Use renderTUI() for integration tests:

import { renderTUI } from "@effect-tui/react/test"

it("renders and handles input", () => {
  const { lastFrame, sendKey, renderNow, unmount } = renderTUI(<Counter />)

  expect(lastFrame()).toContain("Count: 0")

  sendKey({ name: "up" })
  renderNow()

  expect(lastFrame()).toContain("Count: 1")
  unmount()
})

API

Renderer

  • createRenderer(options?) - Create renderer instance
  • createRoot(renderer) - Create React root
  • render(element, options?) - One-liner convenience API

Options

importMeta is required whenever you pass the options object.

type RenderOptions = RendererOptions & {
  dev?: boolean
  importMeta: ImportMetaLike
}

interface RendererOptions {
  fps?: number              // Default: 60
  mode?: "fullscreen" | "inline"
  exitOnCtrlC?: boolean     // Default: true
  handleSignals?: boolean   // Default: true (signals + process exit cleanup)
  manualMode?: boolean      // For testing
}

Environment Variables

  • PROFILE_TUI=1 - Enable profiling (writes to tui-profile.txt)
  • EFFECT_TUI_EDITOR / EDITOR - Editor for trace visualization

License

MIT