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-popup-widget

v1.0.0

Published

A flexible popup widget for React applications

Readme

Creating a Shareable React Package with Popup Widget

I'll show you how to create a React package similar to react-paystack that provides a popup widget. This package will be installable via npm and usable in any React application.

Project Structure

react-popup-widget/
├── src/
│   ├── index.js
│   ├── components/
│   │   ├── PopupWidget.js
│   │   └── PopupButton.js
│   ├── hooks/
│   │   └── usePopupWidget.js
│   ├── contexts/
│   │   └── PopupContext.js
│   └── styles/
│       └── popup.css
├── package.json
├── README.md
├── rollup.config.js (or webpack.config.js)
└── .npmignore

Step 1: Initialize the Package

mkdir react-popup-widget
cd react-popup-widget
npm init -y
Step 2: Install Dependencies
bash
npm install react react-dom
npm install --save-dev @babel/core @babel/preset-env @babel/preset-react rollup rollup-plugin-babel rollup-plugin-commonjs rollup-plugin-node-resolve rollup-plugin-postcss rollup-plugin-terser

...code files

Step 6: Build and Publish

bash
# Build the package
npm run build

# Login to npm (first time only)
npm login

# Publish to npm
npm publish

Step 7: Usage Examples for End Users Users can now install and use your package like this:

Installation

npm install react-popup-widget --save
# or
yarn add react-popup-widget

Usage Examples

1. Using the Hook:

jsx


import React from 'react';
import { usePopupWidget } from 'react-popup-widget';

const MyComponent = () => {
  const { isOpen, open, close } = usePopupWidget();

  return (
    <div>
      <button onClick={() => open()}>Open Popup</button>
      
      {isOpen && (
        <PopupWidget 
          isOpen={isOpen}
          onClose={close}
          title="My Popup"
        >
          <p>This is my popup content!</p>
          <button onClick={close}>Close</button>
        </PopupWidget>
      )}
    </div>
  );
};

2. Using the Button Component:

jsx

import React from 'react';
import { PopupButton } from 'react-popup-widget';

const MyComponent = () => {
  return (
    <PopupButton 
      buttonText="Click to Open"
      widgetTitle="Welcome!"
      position="center"
      onOpen={() => console.log('Popup opened')}
      onClose={() => console.log('Popup closed')}
    >
      <h2>Hello World!</h2>
      <p>This is inside the popup</p>
      <form>
        <input type="text" placeholder="Enter something" />
        <button type="submit">Submit</button>
      </form>
    </PopupButton>
  );
};

3. Using the Context Provider (for global popup management):

jsx

// App.js
import React from 'react';
import { PopupProvider, usePopup } from 'react-popup-widget';

const Content = () => {
  const { showPopup } = usePopup();
  
  const openContactForm = () => {
    showPopup(
      <div>
        <h2>Contact Us</h2>
        <form>
          <input type="text" placeholder="Name" />
          <input type="email" placeholder="Email" />
          <textarea placeholder="Message"></textarea>
          <button type="submit">Send</button>
        </form>
      </div>,
      {
        title: "Contact Form",
        width: "600px",
        position: "center"
      }
    );
  };
  
  return <button onClick={openContactForm}>Contact Us</button>;
};

function App() {
  return (
    <PopupProvider>
      <Content />
    </PopupProvider>
  );
}

export default App;

Additional Features You Can Add

  • Animations: Add more animation types

  • Drag and Drop: Make popups draggable

  • Multiple Popups: Support for stacked popups

  • Accessibility: ARIA labels and keyboard navigation

  • Theming: Customizable CSS variables

  • Async Loading: Lazy load popup content

  • This creates a professional React package similar to react-paystack that users can easily install and use in their React applications!