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

ink-trc

v0.2.0

Published

Ready-to-use Ink components and screen management system for building terminal UIs.

Readme

ink-trc

Ready-to-use Ink components and tools for building terminal UI applications.

CI npm version License: AGPL-3.0


Install

npm install ink-trc

Requirements

| Dependency | Minimum Version | | ---------- | --------------- | | Node.js | 18 | | ink | 5 | | react | 18 |


Design Philosophy

ink-trc aims to make screen management and keyboard event handling in Ink applications composable, maintainable, and type-safe.

Screen as Component

In ink-trc, every React component is a "screen". Register them into a screen tree via registerComponent, then navigate the tree with skip / back / gotoScreen. This design makes screen navigation predictable and eliminates the chaos of hand-written conditional rendering (if-else / switch).

Layered Keyboard Events

No more global useInput cluttered with if-else chains. ink-trc's keyboard system maintains per-screen-layer key bindings. Events bubble from top to bottom through the stack, with three key mechanisms:

  • Blocked Key (blockedKey) — Let a key pass through the current layer to be handled below
  • Stop (stop) — Prevent a key from propagating to layers below
  • Global Key (globalKeys) — Shortcuts independent of the screen stack

Module-Level Functions

Navigation functions (skip, back, gotoScreen, etc.) work both inside React components (via hooks) and as module-level imports in any .ts / .tsx file. This allows non-UI layers — game engines, state managers, etc. — to trigger screen transitions.

Type Safety

Every API provides full TypeScript type inference. Functions like skip, gotoScreen, and overlay automatically infer parameter types from your component's props, catching errors at compile time.


⚠️ Important: Component Nesting Order

KeyboardProvider must be nested inside ScenarioManagementProvider, because it depends on the screen context to obtain the current screen stack.

{/* ❌ Wrong: KeyboardProvider outside screen context */}
<KeyboardProvider>
  <ScenarioManagementProvider defaultScreen={Menu}>
    ...
  </ScenarioManagementProvider>
</KeyboardProvider>

{/* ✅ Correct: KeyboardProvider inside screen context */}
<ScenarioManagementProvider defaultScreen={Menu}>
  <KeyboardProvider>
    ...
  </KeyboardProvider>
</ScenarioManagementProvider>

The screen system can be used independently without KeyboardProvider; but the keyboard system requires the screen context.


Documentation

  • Screen Management SystemregisterComponent, ScenarioManagementProvider, CurrentScreen, useScreenSystem, skip / back / gotoScreen / overlay / closeOverlay
  • Keyboard SystemKeyboardProvider, useKeyboard, boundKeyboard, blockedKey, stop, globalKeys

Quick Overview

import React, { useEffect } from 'react';
import { Box, Text, render } from 'ink';
import {
  registerComponent,
  ScenarioManagementProvider,
  CurrentScreen,
  useScreenSystem,
  KeyboardProvider,
  useKeyboard,
} from 'ink-trc';

// ── Register screens ──
function Menu() {
  const { skip } = useScreenSystem();
  const { boundKeyboard } = useKeyboard();
  useEffect(() => {
    boundKeyboard(['s'], () => skip(Game, { level: 1 }));
  }, []);
  return (
    <Box>
      <Text>Main Menu — Press S to start</Text>
    </Box>
  );
}
registerComponent(Menu, {});

function Game({ level }: { level: number }) {
  const { back } = useScreenSystem();
  const { boundKeyboard } = useKeyboard();
  useEffect(() => {
    boundKeyboard(['b'], () => back());
  }, []);
  return (
    <Box>
      <Text>Level {level} — Press B to go back</Text>
    </Box>
  );
}
registerComponent(Game, { level: 1 }, { parent: Menu });

// ── Wire up ──
function App() {
  return (
    <KeyboardProvider>
      <CurrentScreen />
    </KeyboardProvider>
  );
}

render(
  <ScenarioManagementProvider defaultScreen={Menu}>
    <App />
  </ScenarioManagementProvider>,
);

More

Because this is a special custom lightweight library that cannot be adapted to most components that rely on useInput, more components will be deeply integrated into this system in the future.

License

AGPL-3.0