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

@ilokesto/overlay

v1.0.2

Published

**English** | [한국어](./README.ko.md)

Readme

@ilokesto/overlay

English | 한국어

A small React overlay runtime built on top of @ilokesto/store.

This package provides a provider-scoped overlay core with a built-in host, item lifecycle management, and adapter injection. It is intentionally headless about modal or toast semantics so higher-level packages can build on top of the same runtime without leaking behavior into the core.

Features

  • Provider-scoped overlay runtime instead of a global singleton
  • Built-in host that renders overlay items through an adapter registry
  • Sync and async overlay opening through the same store lifecycle
  • Clean separation between runtime core and shared contracts
  • A small public API for opening, closing, removing, and observing overlays

Installation

pnpm add @ilokesto/overlay react

or

npm install @ilokesto/overlay react

Basic Usage

import { OverlayProvider, useOverlay, type OverlayAdapterMap } from '@ilokesto/overlay';

const adapters: OverlayAdapterMap = {
  modal: ({ isOpen, close, title }) => {
    if (!isOpen) {
      return null;
    }

    return (
      <div role="dialog" aria-modal="true">
        <h1>{String(title)}</h1>
        <button onClick={() => close(true)}>Confirm</button>
      </div>
    );
  },
};

function ExampleButton() {
  const { display } = useOverlay();

  const handleClick = async () => {
    const result = await display<boolean>({
      type: 'modal',
      props: { title: 'Delete this item?' },
    });

    console.log(result);
  };

  return <button onClick={handleClick}>Open</button>;
}

export function App() {
  return (
    <OverlayProvider adapters={adapters}>
      <ExampleButton />
    </OverlayProvider>
  );
}

Source Layout

src/
  core/
    createOverlayStore.ts
    OverlayProvider.tsx
    OverlayHost.tsx
    useOverlay.ts
    useOverlayItems.ts
  contracts/
    adapter.ts
    overlay.ts
  index.ts

Responsibilities

src/core

  • createOverlayStore.ts → creates the provider-scoped overlay store and manages open, close, remove, and clear
  • OverlayProvider.tsx → creates or receives a store, exposes it through context, and mounts the built-in OverlayHost
  • OverlayHost.tsx → reads the current overlay items and dispatches each item to adapters[item.type]
  • useOverlay.ts → exposes the command API for opening and dismissing overlays
  • useOverlayItems.ts → subscribes to the current overlay item list with useSyncExternalStore

src/contracts

  • adapter.ts → adapter-facing rendering contracts such as OverlayRenderProps, OverlayAdapterComponent, and OverlayAdapterMap
  • overlay.ts → overlay runtime contracts such as OverlayItem, OverlayStoreApi, DisplayOptions, and OverlayProviderProps

src/index.ts

  • Re-exports the runtime APIs from core/*
  • Re-exports shared contract types from contracts/*

Dependency Direction

  • core/* depends on contracts/*
  • contracts/overlay.ts depends on contracts/adapter.ts
  • contracts/adapter.ts does not depend on runtime code
  • Adapter packages such as modal or toast should depend on @ilokesto/overlay
  • @ilokesto/overlay should not import modal or toast implementations directly

In short, the core owns lifecycle and hosting, while adapter packages own semantics and presentation.

Adapter Packages

This package is intentionally generic.

  • A modal package can use the overlay runtime and inject modal adapters
  • A toast package can use the same runtime and inject toast adapters
  • Policies such as focus trapping, scroll lock, backdrop behavior, deduplication, timers, and animations belong in the adapter layer, not in the overlay core

Exports

  • @ilokesto/overlaycreateOverlayStore, OverlayProvider, OverlayHost, useOverlay, useOverlayItems
  • @ilokesto/overlay types → contracts from src/contracts/adapter.ts, src/contracts/overlay.ts, and UseOverlayReturn

Development

pnpm install
pnpm run build

Build outputs are generated in the dist directory.

License

MIT