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

@zeroweight/react

v0.2.39

Published

React hooks & components for the ZeroWeight avatar renderer. Drop-in LiveKit-powered avatar sessions.

Readme

@zeroweight/react

React hooks and components for the ZeroWeight avatar renderer. Drop-in LiveKit-powered avatar sessions for React and Next.js.

Installation

npm install @zeroweight/react @zeroweight/renderer

Peer Dependencies

The following are required in your project:

npm install react react-dom

LiveKit, lucide-react, and other dependencies are installed automatically.

Quick Start

Drop-in Component (Simplest)

import { LiveKitAvatarSession } from "@zeroweight/react";

function App() {
  return (
    <LiveKitAvatarSession
      avatarId="your-avatar-id"
      apiKey="your-api-key"
      sessionDuration={120}
      inactivityTimeout={30000}
      turnOffMicWhenAISpeaking
      showBorder={false}
    />
  );
}

This renders a full avatar session with canvas, controls, status badge, and LiveKit voice chat using the built-in defaults:

  • livekitUrl: wss://prod-project-pazuyq69.livekit.cloud
  • API base URL: https://api.zeroweight.ai/api/v1
  • auth header: X-ZW-Api-Key: <apiKey> only when apiKey is provided

That makes it easy to quickly test by pasting an avatarId and apiKey. You can also tune session timing directly on LiveKitAvatarSession with sessionDuration and inactivityTimeout, just like useAvatarSession.

Custom UI (Full Control)

import { useAvatarSession, LiveKitAvatarProvider } from "@zeroweight/react";
import { LiveKitRoom } from "@livekit/components-react";

function CustomAvatar() {
  const session = useAvatarSession({
    avatarId: "your-avatar-id",
    apiKey: "optional-api-key",
    livekitUrl: "wss://...",
    api: { getBundle, getLiveKitToken },
    turnOffMicWhenAISpeaking: true,
  });

  return (
    <div>
      {/* Canvas container — renderer injects <canvas> here */}
      <div ref={session.containerRef} style={{ width: 640, height: 480 }} />

      {/* Your own UI */}
      <p>State: {session.rendererState}</p>
      <button onClick={session.connect}>Connect</button>
      <button onClick={session.disconnect}>Disconnect</button>
      <button onClick={() => session.runAction("wave_hand")}>Wave</button>

      {/* LiveKit room for voice (hidden) */}
      {session.token && (
        <LiveKitRoom
          serverUrl={session.livekitUrl}
          token={session.token}
          connect
          audio
          onConnected={session.markConnected}
          onDisconnected={session.disconnect}
        >
          <LiveKitAvatarProvider session={session} />
        </LiveKitRoom>
      )}
    </div>
  );
}

API

ZeroWeightApi Interface

You can provide your own backend integration via this interface:

interface ZeroWeightApi {
  getBundle: (avatarId: string) => Promise<{ payload: any }>;
  getLiveKitToken: (
    avatarId: string,
    userName: string,
  ) => Promise<{ token: string }>;
}

useAvatarSession(config)

The core React hook. Manages the renderer lifecycle and returns reactive state + imperative methods.

Config:

| Prop | Type | Required | Description | | ------------------- | --------------- | -------- | ---------------------------------------------- | | avatarId | string | ✅ | Avatar ID to load | | apiKey | string \| null| – | Optional API key for the built-in API | | api | ZeroWeightApi | – | Custom API implementation | | turnOffMicWhenAISpeaking | boolean | – | Auto-mute when AI speaks, then unmute after (default: true) | | livekitUrl | string | – | LiveKit server URL | | sessionDuration | number | – | Session limit in seconds (default: 120) | | inactivityTimeout | number | – | Auto-disconnect timeout in ms (default: 30000) |

Default behavior when you do not pass api or livekitUrl:

  • livekitUrl defaults to wss://prod-project-pazuyq69.livekit.cloud
  • getBundle() calls https://api.zeroweight.ai/api/v1/avatars/bundle/:avatarId
  • getLiveKitToken() calls https://api.zeroweight.ai/api/v1/livekit/getToken?avatar_id=:avatarId&name=:randomName
  • X-ZW-Api-Key is attached only if apiKey is non-null

For production use, the recommended setup is still to keep your API key on your server and pass a custom api object that calls your own backend endpoints.

Returns:

| Property | Type | Description | | --------------- | ----------- | -------------------------------------------------------- | | containerRef | RefObject | Attach to a <div> — renderer creates <canvas> inside | | rendererState | string | "idle" | "loading" | "ready" | "error" | | isEngineReady | boolean | true when renderer is ready | | isConnected | boolean | LiveKit connection status | | connect() | function | Start voice session | | disconnect() | function | End voice session | | runAction(id) | function | Trigger an avatar action | | toggleMic() | function | Toggle microphone mute | | setVolume(v) | function | Set audio volume (0–1) |

LiveKitAvatarSession Props

In addition to all useAvatarSession config props above, the drop-in component accepts:

| Prop | Type | Default | Description | | ------------------- | --------------- | ------- | ---------------------------------------------- | | showBorder | boolean | true | Show border and shadow around the container | | style | CSSProperties | – | Style overrides for the outer section | | className | string | – | Class name overrides for the outer section | | loadingContent | ReactNode | – | Custom loading UI for the canvas | | customControls | function | – | Replace default controls (session) => ReactNode | | customStatusBadge | function | – | Replace default status badge (session) => ReactNode |

Components

| Component | Description | | ----------------------- | -------------------------------------------------- | | LiveKitAvatarSession | Full drop-in: canvas + controls + LiveKit | | AvatarCanvas | Canvas container with loading overlay | | AvatarControls | Default mic/connect buttons | | AvatarStatusBadge | Online/offline status indicator | | LiveKitAvatarProvider | LiveKit ↔ renderer bridge (inside <LiveKitRoom>) |

All components accept a session prop from useAvatarSession().

Integration Example

Adapting an existing API service:

import { api } from "./my-api";
import type { ZeroWeightApi } from "@zeroweight/react";

const zeroWeightApi: ZeroWeightApi = {
  getBundle: (avatarId) => api.getBundle(avatarId),
  getLiveKitToken: (_avatarId, userName) => api.getToken(userName),
};

Recommended Production Setup: Custom Endpoint Wiring

If you plan to use this in production, the recommended security practice is to keep your ZeroWeight API key on your server and expose your own backend endpoints to the frontend. That way, the browser never receives your private API key directly, while @zeroweight/react still gets the bundle and LiveKit token it needs.

<LiveKitAvatarSession
  avatarId="your-avatar-id"
  livekitUrl="wss://your-livekit-server.example.com"
  sessionDuration={180}
  inactivityTimeout={45000}
  api={{
    getBundle: (avatarId) =>
      fetch(`/api/avatars/bundle/${avatarId}`).then((r) => r.json()),
    getLiveKitToken: (avatarId, userName) =>
      fetch(
        `/api/livekit/token?avatar_id=${avatarId}&name=${userName}`,
      ).then((r) => r.json()),
  }}
/>

Build from Source

git clone <repo-url>
cd zeroweight-renderer-react
npm install
npm run build

Output in dist/:

  • zeroweight-renderer-react.es.js — ES module (14 KB)
  • zeroweight-renderer-react.cjs.js — CommonJS (11 KB)
  • *.d.ts — TypeScript declarations

Deploy

npm publish --access public

License

MIT