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

treeli

v0.1.3

Published

A declarative TUI framework using JSX and efficient cell-based diffing

Downloads

292

Readme

treeli

A declarative TUI (Terminal User Interface) framework using JSX and efficient cell-based diffing.

Features

  • JSX Syntax - Write terminal UIs with familiar JSX syntax
  • Reactive Primitives - Solid.js-style reactivity with createSignal, createEffect, createMemo
  • Efficient Rendering - Two-tier optimization with Merkle tree hashing and cell-level diffing
  • Flexbox Layout - Intuitive flexbox-inspired layout system
  • Focus Management - Built-in keyboard navigation and focus handling
  • Zero Dependencies - Lightweight with no runtime dependencies

Installation

npm install treeli
# or
bun add treeli
# or
yarn add treeli

Quick Start

import { run, createSignal } from "treeli";

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

  return (
    <box direction="column" padding={1}>
      <text>Count: {count()}</text>
      <text style={{ color: "gray" }}>Press +/- to change, q to quit</text>
    </box>
  );
}

run(App, {
  onKeypress: (key, { exit }) => {
    if (key === "q") exit();
  },
});

JSX Configuration

Configure your tsconfig.json to use treeli's JSX runtime:

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "treeli"
  }
}

API Reference

Components

  • <box> - Container with flexbox layout

    • direction - "row" | "column"
    • justify - "start" | "end" | "center" | "space-between" | "space-around"
    • align - "start" | "end" | "center" | "stretch"
    • padding, margin - Spacing (number or { top, right, bottom, left })
    • width, height, minWidth, minHeight - Sizing
    • border - true | "single" | "double" | "rounded" | "bold"
    • style - { color, background, bold, italic, underline, dim, inverse }
  • <text> - Text content

    • style - Same as box
  • Fragments - <>...</> for vertical stacking without a container

Reactive Primitives

import { createSignal, createEffect, createMemo, batch } from "treeli";

// Signals - reactive state
const [value, setValue] = createSignal(0);
setValue(1);
setValue((prev) => prev + 1);

// Effects - side effects that track dependencies
createEffect(() => {
  console.log("Value changed:", value());
});

// Memos - derived/computed values
const doubled = createMemo(() => value() * 2);

// Batch - group multiple updates
batch(() => {
  setValue(1);
  setOther(2);
});

App Lifecycle

import { run, render, createRoot } from "treeli";

// Simple app with run()
run(App, {
  onKeypress: (key, { exit }) => { /* handle keys */ },
  fullscreen: true,
});

// Manual control with render()
const app = render(App, { fullscreen: true });
app.refresh();
app.cleanup();

Input & Focus

import { createInput, createButton, focus, KEYS } from "treeli";

// Text input
const input = createInput({
  placeholder: "Enter text...",
  onSubmit: (value) => console.log(value),
});

// Button
const button = createButton({
  onPress: () => console.log("Pressed!"),
});

// Focus management
focus.register(input);
focus.register(button);
focus.next(); // Move to next focusable
focus.prev(); // Move to previous

Examples

Check out the examples directory:

# Basic demo
bun examples/demo.ts

# JSX demo
bun examples/jsx-demo.tsx

Architecture

JSX Components → VNode Tree (Merkle hashes) → Layout → Cell Buffer → Diff → ANSI Output
  1. VNode Tree - JSX compiles to virtual nodes with Merkle hashes for change detection
  2. Layout Engine - Flexbox-style positioning calculates absolute coordinates
  3. Cell Buffer - Terminal as 2D matrix of characters + styles
  4. Diffing - Only changed cells are written to terminal

Contributing

See CONTRIBUTING.md for development setup and guidelines.

License

MIT - see LICENSE file for details.