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

@shopkit/navigation

v1.5.0

Published

Navigation menu fetching, types, and context for storefront apps

Readme

@shopkit/navigation

Navigation menu data layer for storefront apps — fetches a merchant's menus (incl. multi-column mega menus) from the backend, validates + caches them, and exposes them to widgets via React Context.

Data + logic only — ships no UI. Each storefront designs its own header/footer and renders the menu however it likes. Think weather API, not weather widget.

Two entry points

// server (layout / Server Components) — fetch only
import { getNavMenus, getNavMenu } from "@shopkit/navigation";

// client (widgets) — provider + hook + helpers
import {
  NavigationProvider,
  useMenu,
  getRenderStrategy,
  getEffectiveUrl,
  hasImage,
  getMegaMenuColumns,
  isBrokenLink,
  getAriaLabel,
} from "@shopkit/navigation/client";

The server barrel uses server-only and must never be imported in a Client Component.

Usage

// 1. Root layout (server): fetch the menus, provide them.
const menus = await getNavMenus();            // fetches "main-menu" + "footer" (defaults)
<NavigationProvider menus={menus}>{children}</NavigationProvider>

// 2. A widget (client): read + render via helpers.
const menu = useMenu("main-menu");
(menu?.items ?? []).map((item) => {
  if (isBrokenLink(item)) return null;
  switch (getRenderStrategy(item)) {
    case "mega-menu": /* getMegaMenuColumns(item) → columns; hasImage(leaf) → card */ break;
    case "dropdown":  /* item.items */ break;
    case "external":  /* <a target="_blank" href={getEffectiveUrl(item)}> */ break;
    case "link":      /* <Link href={getEffectiveUrl(item) ?? "/"}> */ break;
  }
});

Env

| Var | Purpose | |---|---| | NEXT_PUBLIC_NAV_MENU_API_URL | Gateway base incl. /api/v1; the package appends /storefront/nav-menus/{handle} | | NEXT_PUBLIC_MERCHANT_ID | Sent as the gk-merchant-id header |

If unset, fetches return null and widgets degrade gracefully (no crash).

Notes

  • getNavMenus() always fetches the backend's default/protected menus (main-menu, footer); pass extra handles for additional custom menus.
  • The API omits inapplicable keys (no url on mega nodes; external_url only at depth 0) — the schema handles this; render via the helpers, not raw fields.
  • Decide a leaf is a card vs. a text link with hasImage(item), never resource_type.

Full guide: plans/mega-menu/FLOW.md (Widget Author Contract in §4.1).