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 🙏

© 2025 – Pkg Stats / Ryan Hefner

simple-react-chatbot

v1.0.6

Published

A customizable and lightweight React chatbot widget built with TypeScript, Tailwind CSS, and Vite. The package provides a ready-to-use, themeable chat interface with support for predefined questions, dynamic responses, and easy integration with AI or cust

Readme

React Chatbot

npm version npm downloads license bundle size

A customizable and lightweight React chatbot widget built with TypeScript, Tailwind CSS, and Vite.
Easily embeddable into any React project, with support for predefined questions, dynamic responses, and API/AI integrations (like Gemini, OpenAI, or your custom backend).


🎬 Demo

Chatbot Demo


✨ Features

  • ⚡ Lightweight and fast — powered by Vite & TypeScript
  • 🎨 Fully themeable with primary/secondary colors and custom bubble backgrounds
  • 💬 Predefined question support for quick prompts
  • 🤖 Compatible with AI models or any async API (customizable request handler)
  • 📱 Responsive design with expand/collapse & fullscreen support
  • 🛠 Easy to integrate — works with any React project

📦 Installation

npm install simple-react-chatbot
# or
yarn add simple-react-chatbot

🚀 Basic Usage

import { Chatbot } from "simple-react-chatbot";
import "simple-react-chatbot/index.css";

export default function App() {
  const onChatResponse = async (
    question: string,
    setIsLoading: (loading: boolean) => void,
    appendChatResponse: (msg: string) => void
  ) => {
    setIsLoading(true);
    appendChatResponse("This is a sample static response");
    setIsLoading(false);
  };

  return (
    <Chatbot
      botTitle="Raj's Chatbot"
      defaultMsg="Hi! How can I help you today?"
      predefinedQuestions={[
        "Quick Introduction",
        "Contact Details",
        "Work Experience Overview",
        "Compare with Your Job Description",
      ]}
      jdCompareText="Please compare with this JD:"
      errorMsg="Failed to fetch response"
      onChatResponse={onChatResponse}
    />
  );
}

🚀✨ Integration with AI APIs (ChatGPT, Gemini, Grok, … )

import { Chatbot } from "simple-react-chatbot";
import "simple-react-chatbot/index.css";


export default function App() {
const onChatResponse = async (
  question: string,
  setIsLoading: (loading: boolean) => void,
  appendChatResponse: (msg: string) => void
  ) => {
  try {
    setIsLoading(true);
    const response = await fetch(
      `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=${GEMINI_KEY}`,
      {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({
          contents: [
            {
              role: "user",
              parts: [
                {
                  text: question, // 👈 Send user question directly
                },
              ],
            },
          ],
        }),
      }
    );

    if (!response.ok) {
      throw new Error(`HTTP ${response.status}: ${await response.text()}`);
    }

    const data = await response.json();
    const raw =
      data?.candidates?.[0]?.content?.parts?.[0]?.text ??
      data?.candidates?.[0]?.content?.text;

    if (!raw) throw new Error("No response from Gemini");
    appendChatResponse(raw);
  } catch (err: any) {
    console.error("Gemini API error:", err.message ?? err);
    appendChatResponse("⚠️ Something went wrong. Please try again.");
  } finally {
    setIsLoading(false);
  }
};

  return (
    <Chatbot
      botTitle="AI Chatbot"
      defaultMsg="Ask me anything!"
      predefinedQuestions={[
        "Tell me about React",
        "Explain Tailwind CSS",
        "What is Vite?",
      ]}
      errorMsg="Failed to fetch response"
      onChatResponse={onChatResponse}
    />
  );
}

⚙️ Props

| Prop | Type | Default | Description | | --------------------- | --------------------------------------------------------------- | ------------------ | ---------------------------------------------------------- | | botTitle | string | – | Title displayed in the chatbot header | | defaultMsg | string | – | Default welcome message shown on chat open | | predefinedQuestions | string[] | – | List of quick prompts shown under the first message | | jdCompareText | string | – | Special keyword to trigger job description comparison flow | | errorMsg | string | – | Message shown when an API call fails | | primaryHaxColor | string (hex) | #876AE7 | Primary theme color (used in header, buttons, highlights) | | secondaryHaxColor | string (hex) | lighter of primary | Secondary theme color (used in user bubbles, highlights) | | botBubbleHaxColor | string (hex) | #FFFFFF | Background color of floating launcher button | | onChatResponse | (question, setIsLoading, appendChatResponse) => Promise<void> | – | Function to handle fetching and appending responses |