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

heroui-modal-provider

v1.0.0

Published

[![package version](https://img.shields.io/npm/v/heroui-modal-provider.svg?style=flat-square)](https://www.npmjs.com/package/heroui-modal-provider) [![package downloads](https://img.shields.io/npm/dm/heroui-modal-provider.svg?style=flat-square)](https://w

Readme

HeroUI-modal-provider

package version package downloads package license

A fork of mui-modal-provider — but adapted for HeroUI-compatible modals (e.g. from @heroui/react,@heroui/modal) and modern UI frameworks.

HeroUI-modal-provider is a helper based on Context API and React Hooks for simplified work with modals (dialogs) built on HeroUI or custom solutions with suitable props.

Huge thanks to the original mui-modal-provider maintainers for the clean architecture and API inspiration.
This fork brings full support for <Modal /> from HeroUI and async control.


📦 Installation

npm install heroui-modal-provider
# or
yarn add heroui-modal-provider

🚀 Quick Start

import { ModalProvider, useModal } from "heroui-modal-provider";
import { Modal, ModalContent, ModalHeader, ModalBody, ModalFooter, Button } from "@heroui/react";

const MyModal = ({ isOpen, onClose }) => (
  <Modal isOpen={isOpen} onClose={onClose}>
    <ModalContent>
      {(close) => (
        <>
          <ModalHeader>My Modal</ModalHeader>
          <ModalBody>This modal is controlled via modal-provider.</ModalBody>
          <ModalFooter>
            <Button color="primary" onPress={close}>Close</Button>
          </ModalFooter>
        </>
      )}
    </ModalContent>
  </Modal>
);

function App() {
  const { showModal } = useModal();

  return (
    <Button onPress={() => showModal(MyModal)}>
      Open Modal
    </Button>
  );
}

// in root
<ModalProvider>
  <App />
</ModalProvider>

💡 Access Modals Anywhere with getModal()

Want to show modals from outside component? Use getModal():

import { getModal } from "heroui-modal-provider";
import MyModal from "./MyModal";

// Wrap your App first
<ModalProvider>
	<App/>
</ModalProvider>

const showModal = ()=>{
	getModal()?.showModal(MyModal, { title: "Hello" });
}

💡 If You’re Using Next.js

Show Modals Anywhere (with Dynamic Import)

Want to open a modal outside the React tree in Next.js? Use getModal() with dynamic import:

import dynamic from "next/dynamic";
import { getModal } from "heroui-modal-provider";

const showModal = async () => {
    // Dynamically import the modal with SSR disabled
    const MyModal = await import("./MyModal").then((mod) => mod.default);
    getModal()?.showModal(MyModal, { title: "Hello" });
};

// Wrap your app with <ModalProvider> in _app.tsx
<ModalProvider>
    <Component {...pageProps} />
</ModalProvider>

Internally, this uses a modal-nexus registry that syncs the current modal context. Once <ModalProvider> is mounted, getModal() exposes:

  • showModal(Component, props?, options?)
  • hideModal(id)
  • destroyModal(id)
  • updateModal(id, nextProps)

Returned modal instances also include:

const modal = showModal(...);

modal.hide();
modal.destroy();

🧩 Modal Options

All modal-related methods accept optional options:

| Option | Type | Description | |------------------|-----------|----------------------------------------| | rootId | string | Group modals under a root context | | hideOnClose | boolean | Hide modal when onClose is triggered | | destroyOnClose | boolean | Destroy modal after closing |


🔧 Advanced Usage

  • Use updateModal(id, props) to patch a modal
  • Use destroyModalsByRootId(rootId) to batch remove grouped modals
  • Use disableAutoDestroy: true in useModal() to persist modals manually

Made by Cr0WD