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

@foundrykit/menu-plugin

v0.2.0

Published

A plugin for Payload CMS that provides a flexible and customisable menu system.

Readme

@foundrykit/menu-plugin

A Payload CMS v3 plugin that adds a configurable menu management system to the admin panel. It lets you model nested navigation, fetch menus by slug, and consume them from regular frontend code without depending on Payload admin UI context.

Features

  • Multiple item types: internal, external, reference, anchor, mailto, tel, custom
  • Nested dropdown menus with configurable depth
  • Admin URL field UI for internal paths, phone numbers, anchors, and email links
  • Public GET /api/menus/:slug endpoint with locale and depth support
  • Optional import/export endpoints with admin-only access by default
  • Server-side menu caching with automatic invalidation
  • Frontend-safe fetchMenu helper plus a useMenu hook built on top of it
  • Per-item visibility, target, rel, roles, and custom attributes
  • Localized menu identity using slug + locale

Installation

pnpm add @foundrykit/menu-plugin

Quick Start

import { buildConfig } from 'payload'
import { menuPlugin } from '@foundrykit/menu-plugin'

export default buildConfig({
  plugins: [
    menuPlugin({
      baseUrl: 'https://example.com',
      relationTo: ['pages', 'posts'],
    }),
  ],
})

This registers a menus collection in Payload.

Configuration

| Option | Type | Default | Description | |---|---|---|---| | baseUrl | string | '' | Base URL prefix shown for internal links in the admin | | cacheTTL | number | 60000 | Server cache TTL in milliseconds | | disabled | boolean | false | Keep the collection schema, but disable plugin runtime endpoints, hooks, and admin helper UI | | enableImportExport | boolean | true | Register the import/export endpoints | | maxDepth | number | 2 | Maximum nesting depth for dropdown items | | relationTo | string \| string[] | 'pages' | Collection(s) available for reference links | | requireAdminForImportExport | boolean | true | Require an authenticated admin user for import/export endpoints |

Example:

menuPlugin({
  baseUrl: 'https://mysite.com',
  cacheTTL: 300_000,
  maxDepth: 3,
  relationTo: ['pages', 'posts', 'products'],
})

Menu Identity and Locales

Menus are uniquely identified by slug + locale.

  • slug: "main-menu", locale: "en" and slug: "main-menu", locale: "fr" can coexist
  • locale values are normalized to lowercase
  • a menu with no locale is treated as a separate default variant

REST API

Get a menu by slug

GET /api/menus/:slug

Query parameters:

  • locale: optional locale variant
  • depth: Payload relationship depth, default 0

Example:

curl 'https://example.com/api/menus/main-menu?locale=en&depth=1'

Export menus

GET /api/menus-export

By default this requires an authenticated admin user.

Import menus

POST /api/menus-import
Content-Type: application/json

Accepts either a JSON array of menu documents or { "menus": [...] }.

Imports upsert by slug + locale.

Example response:

{
  "created": 1,
  "updated": 2,
  "errors": []
}

Frontend Usage

fetchMenu

Use fetchMenu anywhere you have a fetch implementation, including server components and non-Payload frontend code.

import { fetchMenu } from '@foundrykit/menu-plugin/rsc'

const menu = await fetchMenu({
  slug: 'main-menu',
  locale: 'en',
  depth: 1,
  baseURL: 'https://example.com',
})

useMenu

'use client'

import { useMenu } from '@foundrykit/menu-plugin/client'

export function Navigation() {
  const { error, isLoading, menu } = useMenu({
    slug: 'main-menu',
    locale: 'en',
    depth: 1,
    baseURL: 'https://example.com',
  })

  if (isLoading) return <div>Loading...</div>
  if (error) return <div>{error}</div>
  if (!menu) return null

  return <pre>{JSON.stringify(menu, null, 2)}</pre>
}

useMenu includes a 30 second client-side cache and aborts in-flight requests on unmount.

Caching

  • Menus are cached after the first GET request
  • cache keys include slug, locale, and depth
  • cache entries are invalidated on create, update, and delete
  • default server TTL is 60 seconds and is configurable via cacheTTL

Requirements

  • Payload CMS v3
  • Node.js 18.20.2+ or 20.9.0+

License

MIT