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

react-chatgpt-widget

v1.0.1

Published

A customizable React component that provides a floating chatbot interface using OpenAI GPT API

Downloads

36

Readme

🤖 React ChatGPT Widget

Add a smart AI chatbot to your website in just 2 minutes!

This package gives you a floating chat button that opens into a full AI assistant powered by ChatGPT. Perfect for customer support, FAQ answers, or just helping your visitors.

🎯 What is this?

Imagine having a helpful AI assistant that sits in the corner of your website, ready to answer questions 24/7. That's exactly what this widget does!

  • Floating chat button that doesn't interfere with your website
  • Smart AI responses using OpenAI's ChatGPT
  • Easy setup - just add one line of code
  • Customizable - change colors, position, and behavior
  • No server needed - works entirely in the browser

🚀 Quick Start (2 minutes)

Step 1: Install the package

npm install react-chatgpt-widget

Step 2: Get an OpenAI API key

  1. Go to OpenAI Platform
  2. Sign up or log in
  3. Click "Create new secret key"
  4. Copy the key (starts with sk-)

Step 3: Add to your React app

import { ChatGPTWidget } from 'react-chatgpt-widget';

function App() {
  return (
    <div>
      <h1>My Website</h1>
      <p>Welcome to my site!</p>
      
      {/* Add the AI chatbot */}
      <ChatGPTWidget 
        apiKey="sk-your-openai-api-key-here"
      />
    </div>
  );
}

That's it! 🎉 Your website now has an AI chatbot!

🎨 What it looks like

When someone visits your website, they'll see:

  1. A chat button in the bottom-right corner
  2. When clicked, it opens a chat window
  3. Users can ask questions and get AI responses
  4. The chat remembers the conversation

⚙️ Customization Options

Change the position

<ChatGPTWidget 
  apiKey="your-key"
  position="bottom-left"  // Options: bottom-right, bottom-left, top-right, top-left
/>

Change the theme

<ChatGPTWidget 
  apiKey="your-key"
  theme="dark"  // Options: light, dark
/>

Add voice input

<ChatGPTWidget 
  apiKey="your-key"
  enableMicrophone={true}  // Users can speak instead of type
/>

Add typing animation

<ChatGPTWidget 
  apiKey="your-key"
  enableTypingAnimation={true}  // AI responses appear word by word
/>

Customize the AI's personality

<ChatGPTWidget 
  apiKey="your-key"
  systemPrompt="You are a friendly customer service representative. Always be helpful and polite."
/>

🔧 Complete Example

import { ChatGPTWidget } from 'react-chatgpt-widget';

function App() {
  return (
    <div>
      <h1>My Online Store</h1>
      <p>Welcome! Need help? Chat with our AI assistant.</p>
      
      <ChatGPTWidget 
        apiKey="sk-your-openai-api-key-here"
        systemPrompt="You are a helpful customer service agent for an online store. Help customers with product questions, orders, and general support."
        position="bottom-right"
        theme="light"
        enableMicrophone={true}
        enableTypingAnimation={true}
        quickPrompts={[
          "What are your shipping options?",
          "How do I return an item?",
          "What's your return policy?",
          "Do you ship internationally?"
        ]}
      />
    </div>
  );
}

💡 Use Cases

  • Customer Support: Answer common questions automatically
  • FAQ Bot: Help users find information quickly
  • Lead Generation: Collect contact info through conversation
  • Product Recommendations: Suggest products based on user needs
  • Booking Assistant: Help with appointments or reservations
  • Educational Tool: Explain concepts or provide tutorials

🔒 Security & Privacy

  • API key: Store it in environment variables for production
  • Data: Chat history is stored locally in the user's browser
  • No server: All processing happens through OpenAI's secure API

Environment Variables (Recommended)

# Create a .env file
REACT_APP_OPENAI_API_KEY=sk-your-actual-api-key
<ChatGPTWidget 
  apiKey={process.env.REACT_APP_OPENAI_API_KEY}
/>

🛠️ Troubleshooting

"Widget doesn't appear"

  • Make sure you have a valid OpenAI API key
  • Check that the component is imported correctly
  • Verify your React app is running

"API key error"

  • Ensure your OpenAI account has credits
  • Check that the API key is correct
  • Make sure you're using the right key format (starts with sk-)

"Voice doesn't work"

  • Voice input requires HTTPS in production
  • Make sure the user grants microphone permission
  • Check browser compatibility

📱 Browser Support

  • ✅ Chrome (recommended)
  • ✅ Firefox
  • ✅ Safari
  • ✅ Edge
  • ⚠️ Voice input needs HTTPS in production

💰 Cost

  • Widget: Free to use
  • OpenAI API: Pay per use (very cheap)
    • ~$0.002 per 1K tokens (about 750 words)
    • Typical conversation: $0.01-0.05
    • 1000 conversations ≈ $10-50

🤝 Need Help?

  • Documentation: Check the examples above
  • Issues: Create a GitHub issue
  • Questions: Ask in the GitHub discussions

📄 License

MIT License - you can use this in any project, commercial or personal.


Made with ❤️ for React developers who want to add AI to their websites easily!