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

heygen-avatar-widget

v1.1.1

Published

A customizable AI Avatar Widget using HeyGen streaming avatars

Downloads

23

Readme

HeyGen Avatar Widget

A customizable React component to embed HeyGen AI avatars in any React application.

Features

  • Simple drop-in widget for any React app
  • Customizable avatar, knowledge base, and appearance
  • Streaming avatar video with real-time responses
  • Voice and text chat interfaces
  • Compatible with React 17+ and TypeScript
  • Enhanced error handling and debugging (v0.1.8+)
  • Direct API integration as fallback (v0.1.8+)

Installation

npm install heygen-avatar-widget @heygen/streaming-avatar
# or
yarn add heygen-avatar-widget @heygen/streaming-avatar

Prerequisites

This package requires the following:

  1. HeyGen API account with:
    • A valid API token
    • At least one avatar created
  2. An API endpoint in your application to fetch a streaming token

Usage

import { AvatarWidget } from "heygen-avatar-widget";
import "heygen-avatar-widget/styles.css"; // Import styles

function App() {
  return (
    <div className="App">
      <h1>My App with HeyGen Avatar</h1>

      {/* The widget will appear as a floating button */}
      <AvatarWidget
        avatarId="your-avatar-id"
        avatarName="Tyler-insuit-20220721"
        openingMessage="Hello! I'm Aiva. How can I help you today?"
      />
    </div>
  );
}

export default App;

API Reference

AvatarWidget Props

| Prop | Type | Required | Default | Description | | ---------------- | ------ | -------- | --------------------------- | ---------------------------------------------------------------------- | | knowledgeID | string | No | - | HeyGen knowledge base ID | | avatarId | string | Yes | Default avatar | ID of the HeyGen avatar to use | | avatarName | string | Yes | - | Specific avatar name to use (e.g. "Thaddeus_ProfessionalLook2_public") | | openingMessage | string | No | - | First message spoken by the avatar | | apiUrl | string | No | "https://api.heygen.com/v1" | Base URL for the HeyGen API | | className | string | No | "" | Additional CSS classes for the widget button |

Troubleshooting

"Cannot read properties of undefined (reading 'GOOD')" or "Cannot read properties of undefined (reading 'Low')"

If you encounter these errors, ensure:

  1. You've installed @heygen/streaming-avatar as a dependency along with this package
  2. If using Vite, configure it to properly resolve the dependency:
// vite.config.js
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

export default defineConfig({
  plugins: [react()],
  optimizeDeps: {
    include: ["@heygen/streaming-avatar"],
  },
});

NEW IN v0.1.8: This version includes fallbacks for common enum issues, which should resolve many of these errors automatically. If you're still experiencing issues, check the full troubleshooting guide in TROUBLESHOOTING.md.

No API calls after token retrieval

If you're experiencing issues where the avatar initializes but no API calls are made after token retrieval:

  1. Check browser console for detailed logs
  2. Ensure your backend is providing a valid HeyGen streaming token
  3. Verify network connectivity to HeyGen's API endpoints
  4. Make sure your HeyGen API key has proper permissions

See the complete troubleshooting guide in TROUBLESHOOTING.md for more details.

Backend Integration

This widget attempts to fetch a streaming token from the /api/avatar/streaming-token endpoint on your backend. You need to implement this endpoint to provide a valid HeyGen streaming token.

Example implementation using Express:

// Example Express endpoint
app.post("/api/avatar/streaming-token", async (req, res) => {
  try {
    const response = await fetch("https://api.heygen.com/v1/streaming/token", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-Api-Key": process.env.HEYGEN_API_KEY,
      },
    });

    const token = await response.text();
    res.send(token);
  } catch (error) {
    console.error("Error getting streaming token:", error);
    res.status(500).send("Failed to get streaming token");
  }
});

Styling

The widget uses Tailwind CSS utility classes by default. You can override styles by providing custom CSS classes.

Additional Resources

Version History

  • 1.0.0 - First stable release with all features fully functional
  • 0.3.8 - Final pre-release version with improvements and fixes
  • 0.1.8 - Enhanced debugging, direct API integration, improved error handling
  • 0.1.7 - Added fallback mechanisms for API compatibility
  • 0.1.6 - Initial public release

License

MIT