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

@monology-io/chat-widget

v1.0.5

Published

Monology Chat Widget

Readme

@monology-io/chat-widget

npm version License: MIT

Official React/Next.js package for embedding the Monology chat widget into your application. Build intelligent, conversational experiences with ease.

🚀 Features

  • React & Next.js Support - Works seamlessly with both React and Next.js applications
  • TypeScript Ready - Full TypeScript support with type definitions included
  • User Identity Tracking - Pass authenticated user data for personalized experiences
  • Customizable - Control widget behavior, appearance, and interactions
  • Lightweight - Optimized bundle size with minimal dependencies
  • SSR Compatible - Works with Next.js App Router and Pages Router

📦 Installation

npm install @monology-io/chat-widget

Or using yarn:

yarn add @monology-io/chat-widget

Or using pnpm:

pnpm add @monology-io/chat-widget

🎯 Quick Start

Basic React Usage

import { RenderWidget } from "@monology-io/chat-widget";

export default function App() {
  return (
    <div className="App">
      <RenderWidget urlId="your-widget-url-id" identity={null} />
    </div>
  );
}

Next.js App Router (Recommended)

For Next.js 13+ with App Router, use dynamic import with SSR disabled:

"use client";
import dynamic from "next/dynamic";

const RenderWidget = dynamic(
  () => import("@monology-io/chat-widget").then((mod) => mod.RenderWidget),
  { ssr: false },
);

export default function App() {
  return (
    <div className="App">
      <RenderWidget urlId="your-widget-url-id" identity={null} />
    </div>
  );
}

Next.js Pages Router

import { RenderWidget } from "@monology-io/chat-widget";

export default function Home() {
  return (
    <div>
      <h1>My App</h1>
      <RenderWidget urlId="your-widget-url-id" identity={null} />
    </div>
  );
}

📖 Usage Examples

With User Identity

Pass authenticated user information for personalized conversations and tracking:

import { RenderWidget } from "@monology-io/chat-widget";

export default function App() {
  return (
    <div className="App">
      <RenderWidget
        urlId="your-widget-url-id"
        identity={{
          id: "user-123",
          firstName: "John",
          lastName: "Doe",
          email: "[email protected]",
          phone: "1234567890",
          company: {
            id: "company-456",
            name: "Acme Inc",
          },
        }}
      />
    </div>
  );
}

Manual Control (Custom Trigger Button)

Control when the widget opens and closes with your own UI:

import { RenderWidget } from "@monology-io/chat-widget";
import { useState } from "react";

export default function App() {
  const [isWidgetOpen, setIsWidgetOpen] = useState(false);

  return (
    <div className="App">
      <button onClick={() => setIsWidgetOpen(true)}>Open Chat Support</button>

      {isWidgetOpen && (
        <RenderWidget
          urlId="your-widget-url-id"
          onClose={() => setIsWidgetOpen(false)}
          hideLauncherButton={true}
          identity={null}
        />
      )}
    </div>
  );
}

TypeScript Example

import { RenderWidget } from "@monology-io/chat-widget";
import type { Identity } from "@monology-io/chat-widget";

interface Props {
  user: Identity | null;
}

export default function ChatWidget({ user }: Props) {
  return <RenderWidget urlId="your-widget-url-id" identity={user} />;
}

🔧 API Reference

<RenderWidget /> Props

| Prop | Type | Required | Default | Description | | -------------------- | ------------------ | -------- | ------- | ---------------------------------------------- | | urlId | string | ✅ Yes | - | Your widget URL ID from the Monology dashboard | | identity | Identity \| null | ❌ No | null | User identity object for authenticated users | | hideLauncherButton | boolean | ❌ No | false | Hide the default launcher button | | onClose | () => void | ❌ No | - | Callback function when widget is closed |

Identity Object

interface Identity {
  id: string; // Unique user identifier
  firstName?: string; // User's first name
  lastName?: string; // User's last name
  email?: string; // User's email address
  phone?: string; // User's phone number
  company?: {
    id: string; // Company identifier
    name: string; // Company name
  };
}

⚠️ Important CSS Warning

The host site should NOT have CSS directly applied to semantic HTML elements like p, a, ul, li, h1-h6, etc.

Why?

Global CSS rules on these elements will conflict with the widget's internal styles and disturb its appearance.

Solution

Use CSS classes or scoped styles instead of element selectors. For example:

  • ❌ Bad: p { margin: 0; }
  • ✅ Good: .my-paragraph { margin: 0; }

🌟 Best Practices

  1. Load Asynchronously - Use dynamic imports in Next.js to avoid blocking initial page load
  2. Pass User Data When Available - If users are logged in, pass their identity to enable tracking and skip verification
  3. Test on Staging First - Verify the widget works correctly before deploying to production
  4. Handle Errors Gracefully - Wrap the widget in error boundaries for production apps
  5. Optimize Bundle Size - Use tree-shaking and code splitting to minimize impact

📚 Documentation

For complete documentation, visit:

🔗 Links

🆘 Support

Need help? We're here for you:

📝 License

MIT © Monology


Made with ❤️ by the Monology team