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

@ai-presence/react

v0.1.6

Published

React bindings for AI Presence Kit presence runtimes.

Readme

@ai-presence/react

React binding helpers for AI Presence Kit. The package depends on the renderer-agnostic core runtime and adapter helpers, and leaves React itself as a peer dependency.

For Vercel AI SDK useChat, use the package-shaped hook to map status, messages, and assistant text into presence state, trace evidence, and DOM attributes:

import { createPresenceReactBindings } from "@ai-presence/react";

const {
  PresenceProvider,
  useVercelAIPresence,
} = createPresenceReactBindings(React);

function ChatShell({ chat }) {
  const presence = useVercelAIPresence(chat);

  return React.createElement(
    PresenceProvider,
    { runtime: presence.runtime },
    React.createElement("section", presence.evidenceAttributes, chat.status),
  );
}

During a healthy before-output wait, presence.evidenceAttributes includes data-ai-presence-framework="vercel-ai-sdk", data-ai-presence-status="streaming", data-presence-state="waiting", data-presence-phase="before-output", data-assistant-text-empty="true", data-presence-before-output="true", and data-first-output-ms="none". This proves the surface moved before assistant text existed, without importing the SVG face renderer.

The lower-level factory still exposes renderer-agnostic React primitives:

import { createPresenceReactBindings } from "@ai-presence/react";

const {
  PresenceProvider,
  PresenceRenderer,
  PresenceRendererSlot,
  usePresenceControlInputs,
  usePresenceFrameTime,
  usePresenceSnapshot,
  usePresenceState,
  useVercelAIPresence,
  vercelAIPresenceEvidence,
} =
  createPresenceReactBindings(React);

The factory expects React to provide createContext, createElement, useContext, useEffect, useState, and useSyncExternalStore. The presence runtime itself comes from @ai-presence/core, so renderers remain replaceable. Use vercelAIPresenceEvidence() when you need to format the same Vercel AI SDK evidence outside a hook, including browser-global builds.

Use PresenceRendererSlot when a renderer needs the current snapshot, shared control inputs, live frame time, and runtime together:

function CustomPresenceSurface() {
  return React.createElement(
    PresenceRendererSlot,
    null,
    ({ snapshot, controlInputs, frameTimeMs }) => React.createElement(
      "output",
      {
        "data-presence-state": snapshot.state,
        "data-presence-phase": controlInputs.latencyPhase,
      },
      `${snapshot.state} / ${controlInputs.attentionTarget} / ${frameTimeMs}`,
    ),
  );
}

By default, the slot uses frameTimeMs as the now value for control inputs. Pass controlOptions.now or frameOptions.now for deterministic tests or custom clocks.

Use usePresenceControlInputs() when a React surface needs the shared renderer-agnostic control layer:

function PresenceStatus() {
  const inputs = usePresenceControlInputs();
  return `${inputs.latencyPhase} / ${inputs.attentionTarget}`;
}

For before-output postures such as thinking and waiting, the hook exposes inputs like latencyPhase: "before-output" and attentionTarget: "response" without importing the face renderer.

Use usePresenceFrameTime() when a React renderer needs a live millisecond clock for temporal frames between presence state changes:

function PresenceSurface() {
  const snapshot = usePresenceSnapshot();
  const frameTimeMs = usePresenceFrameTime();

  return render(snapshot, { now: frameTimeMs, timeMs: frameTimeMs });
}

The hook defaults to Date.now() so it shares the same epoch as presence runtime snapshots. Pass { now } in tests or deterministic renderers.

The local browser example at examples/react-browser.html uses actual React and ReactDOM UMD builds to exercise the provider, renderer slot component, AI SDK adapter, face renderer mapping, and a non-face status surface driven by the same slot payload. Open examples/react-browser.html?autorun=1 for deterministic before-output evidence in browser smoke tests and release media checks, including data-nonface-renderer="status-surface" and data-nonface-phase="before-output".