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

@copilotlive/react-sdk

v1.1.2

Published

A React component library for integrating the Copilot chat widget into your applications. This library provides a flexible and type-safe way to manage single or multiple Copilot instances with custom tools, user configurations, and full telemetry observab

Readme

React Copilot Widget

A React component library for integrating the Copilot chat widget into your applications. This library provides a flexible and type-safe way to manage single or multiple Copilot instances with custom tools, user configurations, and full telemetry observability.

✨ Features

  • 🔄 Automatic Single/Multi Mode: Automatically detects and supports both single and multiple Copilot instances.
  • 🛠 Custom Tools Integration: Register powerful tools with support for async handlers.
  • 👥 User Management: Easily set/unset user information across sessions.
  • 🪝 Ergonomic Hooks: Intuitive and declarative hooks to register tools, context, eventLoggers, and users via useCopilotTool, useCopilotContext, useTelemetry, and useCopilotUser.
  • 🧠 Smart Resolution: Access Copilot instance by name or index, with graceful fallback and validation.
  • Type-Safe: Built in TypeScript with full type support and validation helpers.
  • 🔌 Simple Integration: Drop-in provider and hook system for seamless integration.
  • 📊 Telemetry Observability: Full telemetry event tracking with fallback handling, throttling, and section-level filtering.

📦 Installation

npm install @copilotlive/react-sdk
# or
yarn add @copilotlive/react-sdk

🚀 Usage

Basic Setup (Single Instance)

import { CopilotProvider } from '@copilotlive/react-sdk';

function App() {
  return (
    <CopilotProvider
      token="your-copilot-token"
      config={{ theme: 'light', position: 'bottom-right' }}
    >
      <YourApp />
    </CopilotProvider>
  );
}

Telemetry Usage

import { useTelemetry } from '@copilotlive/react-sdk';
import { TelemetryEvent } from '@copilotlive/react-sdk/types';

// All events
const all = useTelemetry();

// All 'user:*' events
const userEvents = useTelemetry(TelemetryEvent.User);

// Specific telemetry
const widgetClose = useTelemetry(TelemetryEvent.Widget.Close);

// Only unknown/unclassified telemetry
const unknown = useTelemetry(TelemetryEvent.Other);

// Throttled
const throttled = useTelemetry(TelemetryEvent.Call.Connect, { throttleDuration: 1000 });

Multiple Instances (Auto-detected)

import { CopilotProvider } from '@copilotlive/react-sdk';

function App() {
  return (
    <CopilotProvider
      instances={[
        { token: 'token-1', config: { theme: 'light' } },
        { token: 'token-2', config: { theme: 'dark' } }
      ]}
    >
      <YourApp />
    </CopilotProvider>
  );
}

Registering Tools via Component

import { Copilot, ToolDefinition } from '@copilotlive/react-sdk';

const tools: ToolDefinition[] = [
  {
    name: 'get_user_info',
    description: 'Retrieves user info',
    parameters: {
      type: 'object',
      properties: {
        userId: { type: 'string', description: 'User ID' },
      },
      required: ['userId']
    },
    handler: async ({ userId }) => fetch(`/api/users/${userId}`).then(res => res.json())
  }
];

function ToolsLoader() {
  return <Copilot tools={tools} />;
}

Register Tool via Hook

import { useCopilotTool } from '@copilotlive/react-sdk';

useCopilotTool({
  name: 'calculate_sum',
  description: 'Adds two numbers',
  parameters: {
    type: 'object',
    properties: {
      a: { type: 'number' },
      b: { type: 'number' }
    },
    required: ['a', 'b']
  },
  handler: ({ a, b }) => ({ result: a + b })
}, { removeOnUnmount: true });

Set/Unset User via Hook

import { useCopilotUser } from '@copilotlive/react-sdk';

useCopilotUser({
  id: 'user123',
  name: 'Jane Doe',
  email: '[email protected]'
}, { unsetOnUnmount: true });

Set/Unset Context via Hook

import { useCopilotContext } from '@copilotlive/react-sdk';

useCopilotContext(
  {
    description: "Product the user is viewing",
    store: "product",
    value: {
      product_id: "12345",
      product_name: "Men's Classic T-Shirt",
      price: 19.99,
      currency: "USD",
      in_stock: true,
    },
  },
  {
    unsetOnUnmount: true,
  }
);

Controlling Instances

import { useCopilot } from '@copilotlive/react-sdk';

function Controls() {
  const copilot = useCopilot(); // Defaults to index 0

  return (
    <>
      <button onClick={() => copilot.show?.()}>Open</button>
      <button onClick={() => copilot.hide?.()}>Close</button>
    </>
  );
}

By Index or Name

const copilotA = useCopilot('copilot1');
const copilotB = useCopilot(1);

📚 API Reference

Includes CopilotProvider, useCopilot, useTelemetry, and all telemetry types.

Refer to source or documentation for full schemas.

🔧 Development

yarn build
yarn typecheck
yarn lint

📦 Package Info

  • Name: @copilotlive/react-sdk
  • Version: 1.0.0
  • License: MIT

🤝 Contributing

We welcome contributions! Open a pull request or issue.

📄 License

MIT License – see the LICENSE file for details.