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

menni

v1.0.0

Published

Simple, headless & type-safe menus library for React

Readme

Menni

Simple, headless & type-safe menus library for React.

Why?

Menni lets you create reactive menus for pluggable application, and allows 3rd parties to extend your application with a set of closed components and their configurations. This is useful for keeping the UI consistent, while still allowing for some amount of extensibility. It's also useful when you want to separate your code into independent packages/modules that extend a host application with their own menu items.

Usage

To start, create a menu using the createMenu function. It accepts a list of components that you want to allow registering into your menu, and an optional list of slots that you want to use to group the menu items (we'll see later on how to use these slots):

import { createMenu } from 'menni';

export const mainMenu = createMenu({
  slots: ['links', 'actions'],
  components: {
    Link: (props: { text: string; href: string }) => (
      <a href={props.href}>{props.text}</a>
    ),
    Button: (props: { text: string; onClick: () => void }) => (
      <button onClick={props.onClick}>{props.text}</button>
    ),
  },
});

Now, use the mainMenu object to register components into the menu. For each component you've provided to createMenu, you'll have a corresponding register{ComponentName} method on the mainMenu object.

Each of these methods accepts a configuration object with the following properties:

  • id: Required. A unique identifier for the menu item.
  • slot: Optional. The slot where the menu item should be placed. Defaults to 'default'.
  • priority: Optional. The priority of the menu item. Lower values will be placed first. Defaults to 10.
  • override: Optional. Whether to override an existing menu item with the same id. Defaults to false.
  • props: Partially Required. The props to pass to the component. These are typed and inferred automatically per component.
  • useProps: Partially Required. A function that replaces the props object and lets you make the them reactive by using hooks.
import { useState } from 'react';
import { mainMenu } from './main-menu';

mainMenu.registerLink({
  id: 'home',
  slot: 'links',
  props: {
    text: 'Home',
    href: '/',
  },
});

mainMenu.registerButton({
  id: 'login',
  slot: 'actions',
  useProps: () => {
    const [isClicked, setIsClicked] = useState(false);

    return {
      text: isClicked ? 'Logout' : 'Login',
      onClick: () => setIsClicked((prev) => !prev),
    };
  },
});

You can also unregister a menu item using the unregister method. It accepts the id of the menu item you want to unregister:

import { mainMenu } from './main-menu';

mainMenu.unregister('home');

Finally, you can render the menu using the useSlotItems hook. It accepts the slot name as an argument, and returns an array of items for that slot, sorted by priority. This hook is reactive, so it will update the UI whenever a menu item is being registered or unregistered from the specific slot you're using:

import { mainMenu } from './main-menu';
import { Logo } from './logo';

const Header = () => {
  const links = mainMenu.useSlotItems('links');
  const actions = mainMenu.useSlotItems('actions');

  return (
    <header>
      <nav>
        <ul>
          {links.map(({ id, MenuItem }) => (
            <li key={id}>
              <MenuItem />
            </li>
          ))}
        </ul>
      </nav>

      <Logo />

      <nav>
        <ul>
          {actions.map(({ id, MenuItem }) => (
            <li key={id}>
              <MenuItem />
            </li>
          ))}
        </ul>
      </nav>
    </header>
  );
};

You can also pass an optional options object to the useSlotItems hook to control its behavior:

function Component() {
  const links = mainMenu.useSlotItems('links', {
    reactive: false, // Whether to re-render the component when the slot items change. Defaults to `true`.
  });

  // ...
}