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-app-registry

v0.1.4

Published

Tiny registry/context to dynamically register and resolve React components (and other items) by key.

Readme

react-app-registry

Tiny registry/context to dynamically register and resolve React components (and other items) by key.

  • Register multiple items per key (e.g., multiple blocks for a region)
  • Resolve all or just the first item
  • Works great for plugin systems, CMS-like blocks, feature renderers

Install

npm i react-app-registry
# or
yarn add react-app-registry

Peer deps: react and react-dom (v18+).

Quick start

'use client'

import React from 'react'
import { RegistryContextProvider, useRegistryContext } from 'react-app-registry'

const Page: React.FC = () => <div>My Page</div>

function Registrar() {
  const { register, getOne } = useRegistryContext()
  React.useEffect(() => {
    register('myFavoriteRenderers', Page)
  }, [register])

  const Comp = getOne('myFavoriteRenderers') as React.FC | undefined
  return <>{Comp ? <Comp /> : null}</>
}

export default function App() {
  return (
    <RegistryContextProvider>
      <Registrar />
    </RegistryContextProvider>
  )
}

API

  • register(key, item) — push one item
  • registerMany(key, items[])
  • loadByKey(key)T[] | undefined
  • requireKey(key)T[] (throws if missing)
  • getOne(key)T | undefined
  • unregister(key, predicate?)
  • clear(key?) (if a key doesn't pass, it will clear all entries)
  • has(key)
  • keys()
  • size()

Server config loader (optional)

If you want to seed the registry from a JSON file at build/server time:

// react-app-registry.config.json
{
  "myFavoriteRenderers": [
    /* importable component references are not JSON-serializable.
       Typically you'll use this to seed non-component data or
       build a handler with file-based registration in Node. */
  ]
}
// server usage (Next.js Route Handler / Server Component / build-time)
import { RegistryContextProvider } from 'react-app-registry'
import { setupRegistry } from 'react-app-registry/server' // or same import if you export it from root
import { ReactNode } from 'react'

export default function Root({ children }: { children: ReactNode }) {
  const handler = setupRegistry(); // Node-only
  return <RegistryContextProvider initial={handler}>{children}</RegistryContextProvider>
}

Note: setupRegistry uses Node’s fs/path. Don’t call it in the browser.

TypeScript

All APIs are generic:

type Renderer = React.FC<{ title: string }>
const handler = new RegistryHandler<Renderer>()
handler.register('card', (p) => <h2>{p.title}</h2>)

// with the hook:
const { register, getOne } = useRegistryContext<Renderer>()

Why?

  • Decouple “who renders” from “who decides what to render”
  • Create block/slot systems without prop-drilling
  • Enable plugin ecosystems (feature flags, A/B tests, themepacks)

License

MIT © Alireza Tabatabaeian