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

@kata-framework/react

v0.2.1

Published

React 19 bindings for the Kata narrative engine. Wrap your app in `KataProvider`, drive the story with `useKata()`, and render frames with your own components.

Readme

@kata-framework/react

React 19 bindings for the Kata narrative engine. Wrap your app in KataProvider, drive the story with useKata(), and render frames with your own components.

Install

bun add @kata-framework/react @kata-framework/core

Quick Start

import { KataProvider, useKata } from "@kata-framework/react";
import { parseKata } from "@kata-framework/core";

const scenes = [parseKata(introSource), parseKata(shopSource)];

function App() {
  return (
    <KataProvider config={{ player: { name: "Hero", gold: 100 } }} initialScenes={scenes}>
      <Game />
    </KataProvider>
  );
}

function Game() {
  const { frame, state, actions } = useKata();

  if (!frame) return <button onClick={() => actions.start("intro")}>Start</button>;

  if (frame.action.type === "text") {
    return (
      <div>
        <strong>{frame.action.speaker}:</strong> {frame.action.content}
        <button onClick={actions.next}>Next</button>
      </div>
    );
  }

  if (frame.action.type === "choice") {
    return (
      <div>
        {frame.action.choices.map((c) => (
          <button key={c.id} onClick={() => actions.makeChoice(c.id)}>
            {c.label}
          </button>
        ))}
      </div>
    );
  }

  return <button onClick={actions.next}>Next</button>;
}

API

<KataProvider>

Creates a single KataEngine instance and exposes it via context.

| Prop | Type | Description | |------|------|-------------| | config | Record<string, any> | Initial engine context (ctx) | | initialScenes | KSONScene[] | Scenes to register on mount | | options | KataEngineOptions | Engine options (e.g. { historyDepth: 100 }) |

useKata()

Subscribe to engine events via useSyncExternalStore. Returns:

| Field | Type | Description | |-------|------|-------------| | frame | KSONFrame \| null | Current frame (null before first update) | | state | object \| null | Current frame.state shortcut | | actions.start(id) | function | Start a scene | | actions.next() | function | Advance to next action | | actions.makeChoice(id) | function | Pick a choice |

useKataEngine()

Direct access to the KataEngine instance from context. Use for advanced operations like engine.back(), engine.use(plugin), engine.getSnapshot(), etc.

<KataDebug />

Optional debug overlay showing scene ID, current action index, and context state. Drop it anywhere inside KataProvider during development.

Architecture

  • KataProvider (src/context.tsx) — creates engine via useRef, exposes via React context
  • useKata() (src/useKata.ts) — useSyncExternalStore subscription to engine events
  • KataDebug (src/KataDebug.tsx) — debug overlay component

Accessibility Hooks

import { useReducedMotion, useKeyboardNavigation, useFocusManagement } from "@kata-framework/react";

// Track prefers-reduced-motion media query
const prefersReduced = useReducedMotion();

// Arrow key + Enter navigation for choices
useKeyboardNavigation(choices, (choiceId) => actions.makeChoice(choiceId));

// Auto-focus an element when a dependency changes
const ref = useFocusManagement(frame);

KataDebug includes ARIA attributes (role="dialog", aria-live="assertive", aria-label) for accessible debug output.

Depends on @kata-framework/core via workspace:*. Peer dependency on React 19.