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

livechat-widget

v1.2.2

Published

LiveChat Widget for Next.js applications

Readme

LiveChat Widget

A customizable real-time chat widget for Next.js applications, built with React and TypeScript. This widget provides seamless integration for live chat functionality during streaming events.

Features

  • Real-time messaging - Instant message delivery via WebSockets
  • Customizable UI - Easily adapt the widget to match your brand
  • Responsive design - Works on desktop and mobile devices
  • Secure authentication - Uses App ID for seamless authentication
  • Easy integration - Simple to add to any Next.js application
  • Admin role support - Special styling for admin messages
  • Tailwind CSS integration - Use Tailwind classes for styling

Installation

# Using npm
npm install livechat-widget

# Using yarn
yarn add livechat-widget

# Using pnpm
pnpm add livechat-widget

Usage

Basic Usage

import { ChatWidgetClient } from 'livechat-widget';

function MyApp() {
  return (
    <div>
      <h1>My Streaming App</h1>
      
      <ChatWidgetClient 
        // Required props
        appId="your-app-id"
        roomCode="room-123"
        apiUrl="https://your-api-url.com"
        wsUrl="wss://your-websocket-url.com"
        userInfo={{
          username: "User123",
          profile_image: "/path/to/profile.png",
          role: "user" // 'admin' or 'user'
        }}
        userCode="user-123"
      />
    </div>
  );
}

Advanced Configuration

import { ChatWidgetClient } from 'livechat-widget';

function MyApp() {
  return (
    <ChatWidgetClient 
      // Required props
      appId="your-app-id"
      roomCode="room-123"
      roomName="Live Stream Chat"
      apiUrl="https://your-api-url.com"
      wsUrl="wss://your-websocket-url.com"
      userInfo={{
        username: "User123",
        profile_image: "/path/to/profile.png",
        role: "user" // 'admin' or 'user'
      }}
      userCode="user-123"
      // Customize appearance
      theme="dark"
      bgColor="#1a1a1a"
      textColor="#ffffff"
      bgInput="#2a2a2a"
      textInputColor="#ffffff"
      currentUserColor="#4caf50"
      adminColor="#9c27b0"
      // Tailwind CSS classes
      bgColorClass="bg-gray-900"
      textColorClass="text-white"
      bgInputClass="bg-gray-800"
      textInputColorClass="text-white"
      currentUserColorClass="text-green-500"
      adminColorClass="text-purple-500"
      buttonBgClass="bg-purple-500"
      // Customize dimensions
      width="400px"
      height="600px"
      // Customize border
      hasBorder={true}
      borderWidth="1px"
      borderColor="#333333"
      borderRadius="8px"
    />
  );
}

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | roomCode | string | Required | Unique identifier for the chat room | | appId | string | Required | Application ID for authentication | | roomName | string | "Chat Room" | Display name for the chat room | | theme | 'light' | 'dark' | 'light' | Color theme of the widget | | bgColor | string | - | Background color of the chat widget | | textColor | string | - | Text color for messages | | bgInput | string | - | Background color of the input field | | textInputColor | string | - | Text color for the input field | | currentUserColor | string | - | Color for the current user's name | | adminColor | string | - | Color for admin user's name | | bgColorClass | string | - | Tailwind class for background color | | textColorClass | string | - | Tailwind class for text color | | bgInputClass | string | - | Tailwind class for input background | | textInputColorClass | string | - | Tailwind class for input text | | currentUserColorClass | string | - | Tailwind class for current user's name | | adminColorClass | string | - | Tailwind class for admin user's name | | buttonBgColor | string | - | Background color for the send button | | buttonBgClass | string | - | Tailwind class for send button background | | userInfo | UserInfo | Required | User information object | | userCode | string | Required | Unique identifier for the user | | width | string | number | "100%" | Width of the chat widget | | height | string | number | "400px" | Height of the chat widget | | hasBorder | boolean | false | Whether to show border | | borderWidth | string | number | "1px" | Width of the border | | borderColor | string | - | Color of the border | | borderRadius | string | number | "4px" | Border radius of the widget | | apiUrl | string | Required | Base URL for the API endpoints | | wsUrl | string | Required | WebSocket server URL |

Types

interface UserInfo {
  username: string;
  profile_image?: string;
  role?: 'admin' | 'user';
}

interface ChatMessage {
  id: string;
  room_code: string;
  app_id: string;
  user_code: string;
  user_info: UserInfo;
  content: string;
  created_at: string;
}

Backend Requirements

This widget requires a compatible backend server that provides:

  1. RESTful API endpoints for:

    • Creating/joining chat rooms
    • Fetching message history
    • User authentication
  2. WebSocket server for real-time messaging

Admin Features

The widget supports special styling for admin users:

  1. Set role: "admin" in the userInfo object to designate a user as admin
  2. Admin messages will be displayed with:
    • Different background color (purple by default)
    • Different text color
    • Visual distinction from regular user messages

Example of setting up an admin user:

<ChatWidgetClient 
  appId="your-app-id"
  roomCode="room-123"
  userInfo={{
    username: "AdminUser",
    profile_image: "/admin.png",
    role: "admin"
  }}
  adminColor="#9c27b0"
  adminColorClass="text-purple-500"
/>

Tailwind CSS Integration

You can use Tailwind CSS classes directly for styling:

<ChatWidgetClient 
  bgColorClass="bg-gray-900"
  textColorClass="text-white"
  currentUserColorClass="text-green-500"
  adminColorClass="text-purple-500"
  buttonBgClass="bg-purple-500"
/>

License

MIT