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

@rara-kit/use-overlay

v0.0.1

Published

A flexible React overlay management system for modals, popovers, tooltips, and other overlay UI components

Readme

@rara-kit/use-overlay

A lightweight and flexible overlay management library for React applications. This library provides an easy way to manage multiple overlays (modals, dialogs, popups, etc.) with both synchronous and asynchronous support.

Overview

@rara-kit/use-overlay offers:

  • 🎯 Simple API for managing overlays
  • ⚡ Support for both synchronous and asynchronous overlays
  • 🔄 Promise-based API for handling overlay results
  • 🎨 Flexible rendering options
  • 📦 Lightweight and zero dependencies (except React)

Installation

npm install @rara-kit/use-overlay
# or
yarn add @rara-kit/use-overlay
# or
pnpm add @rara-kit/use-overlay

Getting Started

1. Provider Setup

First, wrap your application with the OverlayProvider:

import { OverlayProvider } from '@rara-kit/use-overlay';

function App() {
  return (
    <OverlayProvider>
      {/* Your app content */}
    </OverlayProvider>
  );
}

2. Basic Usage

Here's how to use a basic overlay:

import { overlay } from '@rara-kit/use-overlay';

function MyComponent() {
  const handleOpenOverlay = () => {
    const close = overlay.open(({ isOpen, onRequestClose }) => (
      <Modal
        isOpen={isOpen}
        onClose={onRequestClose}
        title="Basic Overlay"
       />
    ));
  };

  return (
    <button onClick={handleOpenOverlay}>
      Open Overlay
    </button>
  );
}

3. Promise-based Usage

You can also use overlays with promises to get user input. The resolve function automatically closes the overlay:

import { overlay } from '@rara-kit/use-overlay';

function MyComponent() {
  const handleOpenAsyncOverlay = async () => {
    try {
      const result = await overlay.openAsync<boolean>(({ isOpen, resolve }) => (
        <Modal
          isOpen={isOpen}
          onClose={() => resolve(false)}
          onSubmit={() => resolve(true)}
          title="Confirmation Required"
        />
      ));

      if (result) {
        // Handle confirmation
      }
    } catch (error) {
      // Handle rejection
    }
  };

  return (
    <button onClick={handleOpenAsyncOverlay}>
      Open Async Overlay
    </button>
  );
}

4. Utility Function Usage

You can create reusable overlay utilities:

// toast.ts
export const showErrorToast = (message: string) => {
  overlay.open(({ isOpen, onRequestClose }) => (
    <div className="fixed top-20 right-20 bg-red-500 text-white p-4 rounded-md">
      <div>{message}</div>
      <button onClick={onRequestClose}>✕</button>
    </div>
  ));
};

// Usage anywhere in your app:
showErrorToast("Something went wrong!");

Best Practices

Create Reusable Overlay Utilities

Extract common overlay patterns into reusable utility functions:

// utils/dialog.ts
export const confirm = (message: string) => {
  return overlay.openAsync<boolean>((props) => (
    <ConfirmDialog
      message={message}
      {...props}
    />
  ));
};

// utils/toast.ts
export const showToast = (message: string) => {
  overlay.open(({ onRequestClose }) => (
    <Toast message={message} onClose={onRequestClose} />
  ));
};

// Usage
const handleDelete = async () => {
  const confirmed = await confirm("Are you sure you want to delete?");
  if (confirmed) {
    try {
      await deleteItem();
      showToast("Successfully deleted");
    } catch {
      showToast("Error occurred while deleting");
    }
  }
};

License

MIT

Source inspired by Toss overlay-kit (MIT License)