pOwn3d

payload nav studio

by pOwn3d
Admin customization
v3
^3.79.1
MIT

Overview

Summary generated from the README

Replaces the default Payload admin sidebar with a navigation each user can rearrange, with layouts stored per user in a dedicated collection. A visual editor view lets users reorder, hide, rename and re-icon groups and items. Without configuration it discovers collections, globals and custom views, and it filters out entries the user cannot read. Requires Payload 3.79.1 or later and Next.js 15 or 16.

Features

  • Drag and drop reordering of groups and items, with touch and keyboard support
  • Per-user layouts stored in a preferences collection, with reset and JSON import and export
  • Zero-config auto-discovery of collections, globals and custom views
  • Permission-aware filtering of entries the current user cannot read
  • Collapsible icon rail, Jump To search and Cmd+K shortcut
  • Multi-language labels and async live badges on groups and sub-items

Use cases

  • Let editors arrange the admin sidebar to match their own workflow
  • Group many collections into a clear custom menu with nested sub-items and icons
  • Show live counters such as open tickets in the admin navigation

From the author

Payload CMS plugin — customizable admin sidebar navigation with drag & drop

Installation

npm i @consilioweb/payload-admin-nav

15

Stars

0

Forks

1

Open Issues

2 months ago

Last Updated

96

Weekly Downloads

v0.19.1

npm Version

638.0 KB

Unpacked Size

0

Dependencies

GitHub stars

15+4 since Sep 7

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 202615
Dec 5, 202615
Dec 4, 202615
Dec 3, 202615
Dec 2, 202615
Dec 1, 202615
Nov 30, 202615
Nov 29, 202615
Nov 28, 202615
Nov 27, 202615
Nov 26, 202615
Nov 25, 202615
Nov 24, 202615
Nov 23, 202615
Nov 22, 202615
Nov 21, 202615
Nov 20, 202615
Nov 19, 202615
Nov 18, 202615
Nov 17, 202615
Nov 16, 202615
Nov 15, 202615
Nov 14, 202615
Nov 13, 202615
Nov 12, 202615
Nov 11, 202615
Nov 10, 202615
Nov 9, 202615
Nov 8, 202615
Nov 7, 202615
Nov 6, 202615
Nov 5, 202615
Nov 4, 202614
Nov 3, 202613
Nov 2, 202613
Nov 1, 202613
Oct 31, 202613
Oct 30, 202613
Oct 29, 202613
Oct 28, 202613
Oct 27, 202613
Oct 26, 202613
Oct 25, 202613
Oct 24, 202613
Oct 23, 202613
Oct 22, 202613
Oct 21, 202613
Oct 20, 202613
Oct 19, 202613
Oct 18, 202613
Oct 17, 202613
Oct 16, 202613
Oct 15, 202613
Oct 14, 202613
Oct 13, 202613
Oct 12, 202613
Oct 11, 202613
Oct 10, 202613
Oct 9, 202612
Oct 8, 202612
Oct 7, 202612
Oct 6, 202612
Oct 5, 202612
Oct 4, 202612
Oct 3, 202612
Oct 2, 202611
Oct 1, 202611
Sep 30, 202611
Sep 29, 202611
Sep 28, 202611
Sep 27, 202611
Sep 26, 202611
Sep 25, 202611
Sep 24, 202611
Sep 23, 202611
Sep 22, 202611
Sep 21, 202611
Sep 20, 202611
Sep 19, 202611
Sep 18, 202611
Sep 17, 202611
Sep 16, 202611
Sep 15, 202611
Sep 14, 202611
Sep 13, 202611
Sep 12, 202611
Sep 11, 202611
Sep 10, 202611
Sep 9, 202611
Sep 8, 202611
Sep 7, 202611
npm weekly downloads

96−64 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 202696
Dec 5, 202682
Dec 4, 202673
Dec 3, 202667
Dec 2, 202654
Dec 1, 202649
Nov 30, 202656
Nov 29, 202660
Nov 28, 202661
Nov 27, 202663
Nov 26, 202679
Nov 25, 202680
Nov 24, 202683
Nov 23, 202677
Nov 22, 202684
Nov 21, 202679
Nov 20, 202675
Nov 19, 202660
Nov 18, 202683
Nov 17, 202678
Nov 16, 202677
Nov 15, 202667
Nov 14, 202669
Nov 13, 202679
Nov 12, 202681
Nov 11, 202652
Nov 10, 202659
Nov 9, 202659
Nov 8, 202664
Nov 7, 202665
Nov 6, 202686
Nov 5, 202690
Nov 4, 2026108
Nov 3, 2026104
Nov 2, 2026128
Nov 1, 2026153
Oct 31, 2026167
Oct 30, 2026171
Oct 29, 2026157
Oct 28, 2026126
Oct 27, 2026128
Oct 26, 2026112
Oct 25, 202687
Oct 24, 2026106
Oct 23, 202669
Oct 22, 202684
Oct 21, 2026124
Oct 20, 2026124
Oct 19, 2026145
Oct 18, 2026149
Oct 17, 2026144
Oct 16, 2026159
Oct 15, 2026173
Oct 14, 2026178
Oct 13, 2026189
Oct 12, 2026175
Oct 11, 2026178
Oct 10, 2026159
Oct 9, 2026164
Oct 8, 2026291
Oct 7, 2026258
Oct 6, 2026246
Oct 5, 2026242
Oct 4, 2026241
Oct 3, 2026270
Oct 2, 2026304
Oct 1, 2026161
Sep 30, 2026173
Sep 29, 2026165
Sep 28, 2026158
Sep 27, 2026149
Sep 26, 2026119
Sep 25, 202679
Sep 24, 202677
Sep 23, 202676
Sep 22, 202682
Sep 21, 202685
Sep 20, 202697
Sep 19, 202698
Sep 18, 2026161
Sep 17, 2026720
Sep 16, 20261,009
Sep 15, 20261,006
Sep 14, 20261,008
Sep 13, 20261,027
Sep 12, 20261,032
Sep 11, 2026995
Sep 10, 2026448
Sep 9, 2026168
Sep 8, 2026170
Sep 7, 2026160

Each point is npm's rolling 7-day download count.

Health Score

66/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1163515462-root.svg)](https://payloaddirectory.dev/plugins/1163515462-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1163515462-root"><img src="https://payloaddirectory.dev/badge/1163515462-root.svg" alt="Payload Directory"></a>
Updated Oct 2, 2026Created Feb 21, 2026Published Sep 29, 2026

README

@consilioweb/payload-admin-nav

A customizable admin sidebar for Payload CMS 3, with drag & drop reordering and per-user layouts stored in the database.

npm license Payload

About

@consilioweb/payload-admin-nav replaces the default Payload admin sidebar with a navigation each user can rearrange for themselves. The layout is persisted per user in a dedicated collection, and a visual editor at /admin/nav-customizer lets them drag & drop groups and items, toggle visibility, rename entries, swap icons and build nested sub-menus without touching code.

Given no configuration, it discovers your collections, globals and custom views and builds the navigation on its own. Given a defaultNav, it uses yours. Either way the server filters out every entry the current user has no read access to, so the sidebar never enumerates what the user cannot open.

Screenshots

Nav CustomizerDrag & Drop
Nav CustomizerDrag & Drop
Item Editor (with sub-menus)Group Editor
Item EditorGroup Editor

Table of Contents

Features

Drag & Drop Navigation

Powered by @dnd-kit, bundled into the package:

  • Group reordering — drag entire sections up and down
  • Item reordering — move items within or across groups
  • Touch & keyboard support
  • Visual drag overlay — see what you are moving in real time

Per-User Preferences

  • Each admin user has their own navigation layout
  • Preferences are stored in a dedicated Payload collection
  • Changes persist across sessions and devices
  • One-click reset to defaults
  • Collapsed groups are remembered per user

Collapsible Rail

  • 72px icon-only rail — the toggle in the sidebar header swaps the full nav for a rail of icons; a chevron at the top of the rail brings the full nav back
  • Persisted per browser, not per user — the state lives in localStorage under admin-nav-rail-collapsed, unlike the layout itself, which is stored in the database
  • The host column follows — html:has(.admin-nav--rail) overrides Payload's --nav-width, so the admin layout reflows instead of leaving an empty gutter
  • Indicators survive the collapse — active state is kept, a live item keeps a green corner dot and a pending badge an amber one, and the user avatar stays pinned to the bottom with its availability popover
  • SSR-safe — the first render is always expanded and the stored value is applied after hydration, so there is no mismatch

Jump To

  • A search field at the top of the sidebar filters items by label — a sub-item label counts as a match for its parent, and a group left with nothing to show disappears
  • Cmd+K / Ctrl+K focuses it from anywhere in the admin, Esc clears and blurs it

Visual Customization

  • Show/hide any group or item
  • Edit labels — rename anything in the sidebar
  • Edit URLs — change where items link to
  • Custom icons — pick from 61 built-in SVG icons, or use a hex color dot
  • Create groups and items — add sections and custom links
  • Nested sub-items — one level of sub-menus, with their own icons
  • Collapse groups — set groups to start collapsed by default
  • Import / export — save a layout as JSON and load it back (files over 1 MB and layouts that fail validation are refused)

Permission-Aware

  • GET /default-nav and GET /discover compute the caller's permissions through getAccessResults() and drop every entry — sub-items included — whose href points at an /admin/collections/<slug> or /admin/globals/<slug> the user cannot read
  • A group left with no visible item disappears with its items
  • Items pointing at custom routes, or at a slug that is not a registered collection or global, are left untouched
  • All six endpoints are restricted to admin-panel users: the caller must belong to config.admin.user and pass that collection's access.admin when one is declared
  • The /admin/nav-customizer view applies that exact same rule before it renders anything. Payload does not gate custom admin views — RootPage skips its canAccessAdmin redirect as soon as the route matches a registered custom view — so every request carrying any valid payload-token reaches the view, including one from a front-office auth collection sharing the cookie. Anyone who is not an admin-panel user is sent to admin.routes.unauthorized instead of receiving the admin shell and the full client config
  • The preferences collection applies the same rule on its own REST route: every operation requires the caller to belong to userCollectionSlug, so an account authenticated against another auth collection (customers, members) is refused even when its numeric id matches an administrator's
  • When permission computation fails (a host access function that throws), every entry pointing at a registered collection or global is hidden instead of shown, and the failure is logged

Auto-Discovery (Zero-Config)

  • No config needed — call adminNavPlugin() with no arguments
  • Collections grouped by their admin.group, globals in a Configuration group, custom views in a Views group
  • Smart icons — 53 slug-to-icon mappings plus substring matching (fallback: box)
  • admin.hidden: true entities are skipped; admin.custom.navHidden: true ones are added hidden (visible: false) so users can re-enable them in the customizer

i18n

  • UI translations — every plugin string is translated in French and English
  • Multi-language labels — item labels and group titles accept string | Record<string, string>
  • Toggle in editor — switch between single-language and multi-language mode per item
  • Fallback chain — exact language → fallback language → first available value
  • Extensible — merged with Payload's deepMergeSimple, so host translations win

Instant Rendering

  • Two-tier cache — module-level (survives SPA navigation) + sessionStorage (survives reload)
  • Cache TTL — 60 seconds, to skip redundant server fetches
  • No loading flash — the nav renders immediately on page transitions
  • SSR-safe — the module cache is null on the server, matching the client's initial state

CSS Architecture

  • BEM naming — classes follow the .admin-nav__element--modifier convention
  • Custom properties — theming through --admin-nav-* variables
  • StyleInjector — the stylesheet is injected at runtime by AdminNav, no import required

Unsaved Changes Guard

  • beforeunload — warns when leaving the customizer with unsaved changes
  • Undo / redo — full history, atomic state updates through useReducer

Installation

pnpm add @consilioweb/payload-admin-nav

Or with npm/yarn:

npm install @consilioweb/payload-admin-nav
yarn add @consilioweb/payload-admin-nav

@dnd-kit is bundled into the customizer build — you do not need to install it separately.

Peer Dependencies

PackageVersionRequired
payload^3.79.1Yes
@payloadcms/ui^3.79.1Yes
@payloadcms/next^3.79.1Yes
next^15.4.11 || ^16.0.0Yes
react^19.0.0Yes
react-dom^19.0.0Yes
@payloadcms/translations^3.79.1Optional (i18n)

Any recent Payload 3 admin app already has all the required ones.

Why 3.79.1 and not 3.0.0? Payload releases below 3.79.1 are affected by a pre-authentication account takeover (GHSA-hp5w-3hxx-vmwf) and by an SQL injection. A plugin peer range that still accepted them told npm those installs were fine, which they are not. The @payloadcms/* packages ship in lockstep with payload, so they carry the same floor.

Next.js 16 + Turbopack

On Next.js 16 with Turbopack (the default bundler), next build may fail with createContext is not a function. This is a known Payload CMS issue (#15429, #14330), not specific to this plugin.

Add this to your admin page (src/app/(payload)/admin/[[...segments]]/page.tsx):

export const dynamic = 'force-dynamic'

And list the @consilioweb/* packages in transpilePackages in next.config.ts:

transpilePackages: ['@consilioweb/payload-admin-nav', /* ...other @consilioweb packages */],

Next.js 15 needs no workaround.

Quick Start

Add the plugin to your payload.config.ts:

import { buildConfig } from 'payload'
import { adminNavPlugin } from '@consilioweb/payload-admin-nav'

export default buildConfig({
  // ... your existing config
  plugins: [
    adminNavPlugin({
      defaultNav: [
        {
          id: 'content',
          title: 'Content',
          items: [
            { id: 'pages', href: '/admin/collections/pages', label: 'Pages', icon: 'file-text' },
            { id: 'posts', href: '/admin/collections/posts', label: 'Posts', icon: 'newspaper' },
            { id: 'media', href: '/admin/collections/media', label: 'Media', icon: 'image' },
          ],
        },
        {
          id: 'settings',
          title: 'Settings',
          items: [
            { id: 'users', href: '/admin/collections/users', label: 'Users', icon: 'users' },
            { id: 'site-settings', href: '/admin/globals/settings', label: 'Settings', icon: 'settings' },
          ],
        },
      ],
    }),
  ],
})

That is all. The plugin will:

  1. Add an admin-nav-preferences collection to store per-user layouts
  2. Register the API endpoints under /api/admin-nav/
  3. Inject the AdminNav component into the sidebar through beforeNavLinks
  4. Add the Nav Customizer view at /admin/nav-customizer

Important: after installing, run pnpm generate:importmap to register the new components.

Zero-Config Mode

Without a defaultNav, the plugin auto-discovers your Payload config and builds the navigation:

import { adminNavPlugin } from '@consilioweb/payload-admin-nav'

export default buildConfig({
  plugins: [
    adminNavPlugin(), // collections, globals and custom views are auto-detected
  ],
})

Auto-discovery will:

  • Group collections by their admin.group value (fallback group: Collections)
  • Add globals to a Configuration group (or to their own admin.group)
  • Add custom admin views to a Views group
  • Guess icons from 53 slug mappings and substring matches (pages → file-text, users → users, media → image, …), falling back to box
  • Skip collections and globals with admin.hidden: true, and add those with admin.custom.navHidden: true as hidden items

autoDiscoverNav() is exported if you want to generate the base layout and change it. It takes the Payload config, so it has to run once the config exists — inside a plugin of your own:

import type { Config, Plugin } from 'payload'
import { buildConfig } from 'payload'
import { adminNavPlugin, autoDiscoverNav } from '@consilioweb/payload-admin-nav'

const navPlugin: Plugin = (config: Config) => {
  const discovered = autoDiscoverNav(config)
  const defaultNav = discovered.filter((group) => group.id !== 'views')
  return adminNavPlugin({ defaultNav })(config)
}

export default buildConfig({
  plugins: [navPlugin],
})

Configuration

adminNavPlugin({
  defaultNav: [],                           // Optional — auto-discovered if omitted
  afterNav: [],                             // Component paths rendered after the nav
  collectionSlug: 'admin-nav-preferences',  // Preferences collection slug
  userCollectionSlug: 'users',              // User collection for the relationship
  endpointBasePath: '/admin-nav',           // API endpoint prefix — keep the default
  addCustomizerView: true,                  // Add the /admin/nav-customizer view
  navComponentPath: undefined,              // Override the AdminNav component path
  navFooterSlot: undefined,                 // Component path replacing the Customize button
  brand: undefined,                         // Sidebar header branding (host identity by default)
})

AdminNavPluginConfig

OptionTypeDefaultDescription
defaultNavNavGroupConfig[]auto-discoveredInitial sidebar structure. When omitted, collections, globals and views are discovered from the Payload config
afterNavstring[][]Component paths appended to admin.components.afterNavLinks
collectionSlugstring'admin-nav-preferences'Slug of the preferences collection
userCollectionSlugstring'users'User collection targeted by the user relationship
endpointBasePathstring'/admin-nav'Base path of the API endpoints. Keep the default — see the warning below
addCustomizerViewbooleantrueRegister the Nav Customizer view at /admin/nav-customizer
navComponentPathstring'@consilioweb/payload-admin-nav/client#AdminNav'Override the beforeNavLinks component path — useful for file: / link: installs, where webpack RSC resolution needs a local wrapper re-exporting AdminNav
navFooterSlotstringnonePayload component path rendered at the bottom of the nav, replacing the default Customize button
brandAdminNavBrandConfighost identitySidebar header (logo + wordmark)

endpointBasePath only moves the server routes. The bundled AdminNav fetches /api/admin-nav/default-nav and /api/admin-nav/badges at those literal paths, and both it and the customizer call useNavPreferences() with no argument, which defaults to '/api/admin-nav'. Setting the option to anything else registers the endpoints elsewhere and the sidebar stops loading. Change it only alongside your own nav component (navComponentPath) that fetches the matching paths and passes the base to useNavPreferences(basePath).

AdminNavBrandConfig

OptionTypeDefaultDescription
wordmarkstring | falseadmin.meta.title, else admin.meta.titleSuffix (Payload's own - Payload default is discarded), else noneText displayed next to the logo. false removes it
logoPathstring | falsenone — the built-in neutral glyphPath to a logo component, imported by the browser at runtime, like navFooterSlot. It must be a path the browser can resolve (a URL, or an entry of the app's import map), not a Payload component path — those are resolved server-side by the importMap and never reach the client. On import failure the built-in glyph is shown
adminNavPlugin({
  brand: { wordmark: 'Acme', logoPath: '/admin-assets/logo.js#default' },
})

// No header branding at all
adminNavPlugin({ brand: { wordmark: false, logoPath: false } })

The plugin never displays its author's name: with no brand and no identity declared by the host, no brand block is rendered at all. The toggle that collapses the nav to the 72px rail is rendered either way.

Advanced Example

adminNavPlugin({
  defaultNav: [
    {
      id: 'content',
      title: { fr: 'Contenu', en: 'Content' },  // Multi-language group title
      items: [
        { id: 'pages', href: '/admin/collections/pages', label: 'Pages', icon: 'file-text' },
        { id: 'posts', href: '/admin/collections/posts', label: { fr: 'Articles', en: 'Blog' }, icon: 'newspaper' },
        { id: 'media', href: '/admin/collections/media', label: { fr: 'Médias', en: 'Media' }, icon: 'image' },
      ],
    },
    {
      id: 'seo',
      title: 'SEO',  // Plain string still works
      defaultCollapsed: true,
      items: [
        { id: 'seo-dashboard', href: '/admin/seo', label: 'Dashboard', icon: 'bar-chart-3', matchPrefix: true },
        { id: 'sitemap', href: '/admin/sitemap-audit', label: 'Sitemap', icon: 'sitemap' },
        { id: 'redirects', href: '/admin/redirects', label: 'Redirects', icon: 'shuffle' },
      ],
    },
    {
      id: 'support',
      title: 'Support',
      items: [
        {
          id: 'tickets',
          href: '/admin/collections/tickets',
          label: 'Tickets',
          icon: 'ticket',
          matchPrefix: true,
          children: [
            { id: 'open', href: '/admin/collections/tickets?status=open', label: 'Open', icon: '#EF4444' },
            { id: 'closed', href: '/admin/collections/tickets?status=closed', label: 'Closed', icon: '#22C55E' },
          ],
        },
      ],
    },
    {
      id: 'admin',
      title: 'Administration',
      items: [
        { id: 'users', href: '/admin/collections/users', label: 'Users', icon: 'users' },
        { id: 'nav-customizer', href: '/admin/nav-customizer', label: 'Customize Nav', icon: 'palette' },
      ],
    },
  ],
  // For file: or link: protocol installs, override the component path:
  // navComponentPath: '@/components/admin/AdminNavWrapper#AdminNav',
})

Types

LocalizedString

type LocalizedString = string | Record<string, string>

Labels and titles accept either a plain string or a per-language record. Both are fully backward-compatible.

NavGroupConfig

interface NavGroupConfig {
  id: string                   // Unique group ID
  title: LocalizedString       // Section header label
  items: NavItemConfig[]       // Items in this group
  visible?: boolean            // Whether the group is visible (default: true)
  defaultCollapsed?: boolean   // Start collapsed (default: false)
  groupBadge?: NavBadgeFn      // Async counter shown next to the group title
}

NavItemConfig

interface NavItemConfig {
  id: string                   // Unique item ID
  href: string                 // Admin URL path
  label: LocalizedString       // Display label
  icon: string                 // Icon name, or '#RRGGBB' for a color dot
  matchPrefix?: boolean        // Activate on pathname.startsWith(href)
  children?: NavChildConfig[]  // Nested sub-items (one level)
  visible?: boolean            // Whether visible (default: true)
  live?: boolean               // Pulsing green dot next to the label
}

NavChildConfig

interface NavChildConfig extends Omit<NavItemConfig, 'children'> {
  childBadge?: NavBadgeFn      // Async counter shown next to the sub-item label
  alert?: boolean              // Render the badge pill in error color
}

NavLayout

interface NavLayout {
  groups: NavGroupConfig[]  // Ordered list of groups
  version: number           // Structural fingerprint used for preference migration
}

Live Badges

A group or a sub-item can carry an async resolver that produces a counter. Resolvers run server-side, in parallel, through GET /admin-nav/badges. GET /admin-nav/default-nav reports whether any resolver is declared through its hasBadges flag, and the client starts polling /badges every 60 seconds only when that flag is true.

import type { NavBadgeFn } from '@consilioweb/payload-admin-nav'

const openTickets: NavBadgeFn = async (req) => {
  const { totalDocs } = await req.payload.count({
    collection: 'tickets',
    where: { status: { equals: 'open' } },
  })
  return totalDocs
}

adminNavPlugin({
  defaultNav: [
    {
      id: 'support',
      title: 'Support',
      groupBadge: openTickets,
      items: [
        {
          id: 'tickets',
          href: '/admin/collections/tickets',
          label: 'Tickets',
          icon: 'ticket',
          children: [
            {
              id: 'tickets-open',
              href: '/admin/collections/tickets?status=open',
              label: 'Open',
              icon: '#EF4444',
              childBadge: openTickets,
              alert: true,
            },
          ],
        },
      ],
    },
  ],
})

A resolver returning null/undefined, or throwing, produces no badge instead of breaking the nav. Negative or non-integer values are clamped. Keep each resolver to one fast query — the response time of the endpoint is that of its slowest resolver.

Internationalization (i18n)

Plugin UI Translations

The plugin ships French and English translations for its UI strings. They are merged into Payload's i18n system with deepMergeSimple, host translations taking precedence.

All keys are namespaced under plugin-admin-nav:

t('plugin-admin-nav:save')      // "Sauvegarder" (FR) / "Save" (EN)
t('plugin-admin-nav:editItem')  // "Modifier l'item" (FR) / "Edit item" (EN)

To override a key or add a language, merge your own translations in payload.config.ts:

import { buildConfig } from 'payload'

export default buildConfig({
  i18n: {
    translations: {
      de: {
        'plugin-admin-nav': {
          save: 'Speichern',
          cancel: 'Abbrechen',
          // ... override any key
        },
      },
    },
  },
})

Multi-Language Nav Labels

Item labels and group titles accept string | Record<string, string>:

adminNavPlugin({
  defaultNav: [
    {
      id: 'content',
      title: { fr: 'Contenu', en: 'Content' },  // Multi-language title
      items: [
        {
          id: 'pages',
          href: '/admin/collections/pages',
          label: { fr: 'Pages', en: 'Pages' },   // Multi-language label
          icon: 'file-text',
        },
        {
          id: 'posts',
          href: '/admin/collections/posts',
          label: 'Blog',                          // Simple string still works
          icon: 'newspaper',
        },
      ],
    },
  ],
})

The item and group editors include a Multi-lang toggle. When a label is already a Record<string, string>, the editor opens in multi-lang mode automatically.

Utilities

import { resolveLabel, isMultiLang } from '@consilioweb/payload-admin-nav'

// Resolve a label to the current language — lang → fallback → first value → ''
resolveLabel({ fr: 'Pages', en: 'Pages' }, 'fr')          // 'Pages'
resolveLabel({ fr: 'Contenu', en: 'Content' }, 'en')      // 'Content'
resolveLabel({ de: 'Inhalt' }, 'en', 'de')                // 'Inhalt'
resolveLabel('Simple string', 'fr')                       // 'Simple string'

// Type guard
isMultiLang({ fr: 'Oui', en: 'Yes' })  // true
isMultiLang('plain')                   // false

usePluginTranslation Hook

Typed wrapper around Payload's useTranslation that knows the plugin's keys:

import { usePluginTranslation } from '@consilioweb/payload-admin-nav/client'

function MyComponent() {
  const { t, i18n } = usePluginTranslation()
  return <span>{t('plugin-admin-nav:save')}</span>
}

Built-in Icons

The plugin ships 61 inline SVG icons with no external dependency. All use a 24x24 viewBox and are Lucide-compatible. Use any name in NavItemConfig.icon:

{ id: 'pages', href: '/admin/collections/pages', label: 'Pages', icon: 'file-text' }

For a color dot instead of an icon, use a hex color:

{ id: 'urgent', href: '/admin/collections/tickets?priority=high', label: 'Urgent', icon: '#EF4444' }
Full icon list (61)

This table is the exact content of the registry (src/icons.ts). Any other name — including Lucide icons not listed here — renders the box fallback and logs a warning outside production.

CategoryIcons
Navigation & Layout (3)home, layout-dashboard, settings
Content (5)file-text, newspaper, image, tag, calendar
Support (7)ticket, message-square, users, folder-kanban, file-up, mail-search, shield-check
Management (4)receipt, clock, mail, clipboard-list
Configuration (3)panel-top, panel-bottom, user-cog
SEO (9)search-check, bar-chart-3, shuffle, layers, activity, search, file-code-2, git-branch, spell-check
Misc (22)plus, minus, x, check, chevron-down, chevron-right, grip-vertical, eye, eye-off, pencil, trash-2, save, rotate-ccw, move, palette, box, star, heart, zap, globe, link, external-link
Maintenance & Tools (8)wrench, bell, history, gauge, target, sitemap, webhook, code

Programmatic Access

import { getIconNames, getIconPath, iconPaths } from '@consilioweb/payload-admin-nav'

const names = getIconNames()        // ['home', 'layout-dashboard', ...]
const path = getIconPath('home')    // SVG path data
Object.keys(iconPaths).length       // 61

API Endpoints

All endpoints are prefixed with the configured endpointBasePath (default: /admin-nav, the only value the bundled client works with — see AdminNavPluginConfig) and are served under /api. Every one of them runs the same guard first: an unauthenticated request gets 401, and a request authenticated against a collection other than config.admin.user — or failing that collection's access.admin — gets 403. Each is rate-limited per user.

MethodPathAccessRate limitDescription
GET/admin-nav/preferencesadmin user60 / minReturn the current user's stored navLayout, version and collapsedGroups (navLayout: null when the user never customized anything)
PATCH/admin-nav/preferencesadmin user30 / minSave the current user's layout
DELETE/admin-nav/preferencesadmin user30 / minDelete the stored layout and fall back to the default
GET/admin-nav/default-navadmin user60 / minDefault nav (permission-filtered), nav version, afterNav, basePath, hasBadges (whether any badge resolver is declared), navFooterSlot, resolved brand
GET/admin-nav/discoveradmin user30 / minAuto-discovery run against the final runtime config (permission-filtered)
GET/admin-nav/badgesadmin user120 / minResolve every groupBadge / childBadge and return { groups, children }

PATCH /admin-nav/preferences validation

A body is refused with 413 when its announced Content-Length exceeds 256 KB, and with 400 when:

  • navLayout has no groups array
  • more than 50 groups, or more than 100 items in a group, or more than 50 children on an entry
  • an item or child is missing href, label or icon, or has an unusable type (href and icon must be strings; label accepts a string or a per-language object)
  • nesting goes deeper than items → children
  • an id exceeds 100 characters, a label 200, an icon 50
  • an href is not a safe relative path — javascript:, data:, vbscript:, //evil.com, /\evil.com and their tab/newline-obfuscated variants are rejected

The same href rule is exported as isSafeHref() and is applied by the customizer's JSON import and by NavItemEditor.

Collections

SlugRoleAccess
admin-nav-preferences (configurable)One row per user: user, navLayout (JSON), collapsedGroups (JSON), versionEvery operation requires the caller to belong to userCollectionSlug; read / update / delete are then restricted to the row whose user is the requester. user is set server-side and is not writable from a request. navLayout and collapsedGroups are validated on write with the same rules as the PATCH endpoint. Hidden from the admin UI (admin.hidden: true)

Components and Hooks

Client (/client)

ExportDescription
AdminNavThe sidebar itself, injected through beforeNavLinks, behind a render boundary (see below)
GroupEditorModal for editing group properties (with multi-lang toggle)
NavItemEditorModal for editing an item, its sub-items and its multi-lang labels
IconPickerIcon dropdown with search and color mode
NavUserProfileUser block rendered at the bottom of the nav
NavFooterSlotLoader for the component declared in navFooterSlot
useNavPreferencesHook reading and saving the nav preferences
usePluginTranslationTyped i18n hook carrying the plugin translation keys

NavCustomizer, SortableGroup and SortableItem are deliberately not re-exported from /client: they pull in @dnd-kit, whose createContext crashes when Turbopack evaluates the barrel in an SSR context. They are reached only through the views entry.

Render boundary

AdminNav renders on every page of the admin panel, and Payload mounts it straight from the import map — so the plugin cannot be given an ancestor error boundary and carries its own instead. A render error inside the sidebar therefore removes the plugin's sidebar and leaves Payload's own navigation working, rather than taking the page down; the error is logged to the console with the component name. /admin/nav-customizer is wrapped the same way, with a visible notice instead, since that page has nothing else to show.

This covers render errors only, which is all a React boundary ever catches. The sidebar's own network calls (/preferences, /default-nav, /badges) are guarded at the call site, where a rejected promise actually lands.

Server views (/views)

ExportPathDescription
NavCustomizerView/admin/nav-customizerAdmin view wrapping the customizer in Payload's DefaultTemplate, behind a render boundary

useNavPreferences

import { useNavPreferences } from '@consilioweb/payload-admin-nav/client'

function MyComponent() {
  const { layout, isLoaded, isCustom, reset } = useNavPreferences()

  if (!isLoaded) return <p>Loading…</p>

  return (
    <div>
      <p>Groups: {layout.length}</p>
      <p>Custom layout: {isCustom ? 'Yes' : 'No'}</p>
      <button onClick={reset}>Reset to defaults</button>
    </div>
  )
}
PropertyTypeDescription
layoutNavGroupConfig[]Current navigation layout (the user's, or the default one)
isLoadedbooleanWhether preferences have been fetched
isSavingbooleanWhether a save or reset is in progress
isCustombooleanWhether the layout differs from the default
save(groups: NavGroupConfig[]) => Promise<boolean>Persist a layout. Returns false when nothing was written — including when the nav version could not be resolved
reset() => Promise<boolean>Delete the stored layout and go back to the default
reload() => Promise<void>Re-fetch preferences from the server
collapsedGroupsstring[]IDs of the groups collapsed by this user
setCollapsedGroups(groups: string[]) => voidUpdate them (debounced save to the server)

save() and reset() return a boolean: check it before showing a success state.

The hook takes two optional arguments — useNavPreferences(basePath = '/api/admin-nav', ownerKey = null).

  • basePath — the /api-prefixed base of the plugin endpoints. Pass it only if you changed endpointBasePath, which also requires replacing the bundled nav component (see AdminNavPluginConfig).
  • ownerKey — the viewer the cache belongs to. Build it with cacheOwnerKey(user) from useAuth(); the bundled components already do. Left out, the hook caches nothing and fetches on every mount, because an unowned cache entry could not be refused to the next account signing in from the same tab.
import { useAuth } from '@payloadcms/ui'
import { cacheOwnerKey, useNavPreferences } from '@consilioweb/payload-admin-nav/client'

const { user } = useAuth()
const { layout } = useNavPreferences('/api/admin-nav', cacheOwnerKey(user))

Caching Strategy

The hook uses a two-tier cache for instant rendering with no flash:

  1. Module-level cache — module-scope variables survive component re-mounts during SPA navigation, so the layout is available immediately in useState().
  2. sessionStorage cache — survives a full page reload. It is read in useEffect (post-hydration) to avoid a hydration mismatch.

On the server the module variables are always null, matching the client's initial state. After the first successful fetch both caches are populated, and a fetch is skipped entirely while the cache is younger than 60 seconds.

Both tiers are stamped with the viewer they were filled for (ownerKey) and are neither read nor reused by anybody else. Neither tier is scoped to a Payload session — sessionStorage lives as long as the tab, the module variables as long as the JS context, and logging out then back in is a same-tab client-side navigation — so without that stamp the next account would inherit the previous one's sidebar and its permission-filtered defaultNav, with the 60-second freshness window preventing any fetch from correcting it. What comes out of the cache is also re-checked with the same rules the fetch applies, so a layout stored before those rules existed is not rendered from cache either.

Package Exports

The package is ESM-only (type: module). There is no CommonJS build: require() will fail at resolution — use import.

SubpathExposesEnvironment
.Plugin, auto-discovery, collection factory, endpoint handlers, icons, utilities, typesServer
./clientReact components and hooks for the admin UIClient
./viewsAdmin views wrapped in Payload's DefaultTemplateServer (RSC)
./styles, ./styles.cssThe raw stylesheet (src/styles/admin-nav.css), for apps that prefer importing it rather than relying on the runtime injectorAny bundler
// Main entry
import {
  adminNavPlugin,
  autoDiscoverNav,
  createAdminNavPreferencesCollection,
  createGetPreferencesHandler,
  createSavePreferencesHandler,
  createResetPreferencesHandler,
  createBadgesHandler,
  getIconNames,
  getIconPath,
  iconPaths,
  resolveLabel,
  isMultiLang,
  isSafeHref,
  computeNavFingerprint,
  dedupeNavItems,
} from '@consilioweb/payload-admin-nav'
import type {
  LocalizedString,
  NavItemConfig,
  NavChildConfig,
  NavGroupConfig,
  NavLayout,
  NavBadgeFn,
  NavBadgesPayload,
  AdminNavPluginConfig,
  AdminNavBrandConfig,
} from '@consilioweb/payload-admin-nav'

// Client components
import {
  AdminNav,
  GroupEditor,
  NavItemEditor,
  IconPicker,
  NavUserProfile,
  NavFooterSlot,
  useNavPreferences,
  usePluginTranslation,
  resolveLabel,
  isMultiLang,
  isSafeHref,
} from '@consilioweb/payload-admin-nav/client'
import type { PluginAdminNavTranslationKeys } from '@consilioweb/payload-admin-nav/client'

// Server views
import { NavCustomizerView } from '@consilioweb/payload-admin-nav/views'

Requirements

Version
Node.js^18.20.2 || >=20.9.0
Payload CMS^3.79.1
Next.js^15.4.11 || ^16.0.0
React / React DOM^19.0.0
DatabaseAny Payload-supported adapter (SQLite, PostgreSQL, MongoDB)

React 18, Next 14, Next 15.0–15.4.10 and Payload below 3.79.1 are no longer supported: installing on them raises an ERESOLVE / peer warning.

Database and updates

This plugin adds a collection to your Payload config; it does not own your schema. Payload has no way for a plugin to ship migrations — payload migrate reads a single directory, the host app's payload.db.migrationDir — so generating and running the DDL is your app's job, exactly as it is for your own collections.

  • In development, push syncs the schema automatically; nothing else to do.
  • In production, run payload migrate:create then payload migrate — never push. It is skipped as soon as NODE_ENV=production, and mixing a pushed schema with migrations makes Drizzle warn about data loss.
  • Every release states in its Upgrading section whether it changes the schema. To date none has.

Upgrading

No schema change. No migration to generate for any release of this plugin so far: the admin-nav-preferences collection has had the same four fields — user, navLayout, collapsedGroups, version — since 0.12.1. Everything below is behaviour, access rules and data.

0.17.x → 0.18.0

  • peerDependencies now require Payload ^3.79.1 (was ^3.0.0) for payload, @payloadcms/next, @payloadcms/ui and the optional @payloadcms/translations. Upgrade the host; check what it actually resolves with pnpm why payload, not what the manifest asks for.
  • /admin/nav-customizer now applies the same gate as the endpoints. Accounts on a second auth collection, and admin-collection members whom access.admin refuses, are redirected to the host's unauthorized view. Nothing to repair in the database: what leaked was read access, and the customizer's writes have gone through PATCH /preferences since 0.16.0.
  • NavCustomizerView is now an async server component. A wrapper that re-exported it typed as React.FC<AdminViewServerProps> no longer typechecks.

0.16.x → 0.17.0

This is the release with data to audit. Two write paths were open before it, and the fix closes them without cleaning up what went through:

  • The preferences collection was reachable on its auto-generated REST route by any authenticated account, on any auth collection, and its user field was writable from the request. A row could therefore be created on somebody else's behalf — and, user being unique, squat the index so that person could never save their own preferences again.
  • navLayout and collapsedGroups were stored unvalidated on that same route. The rules now run as field validate too, but only on the value a request actually sets: an untouched legacy value is left alone and neutralised at render time by the read-side sanitizer. So a stored row can render as something other than what it holds, or not render at all, with no signal anywhere.

Run the audit below once after upgrading.

Auditing existing preference rows

# From the root of your Payload app. Reports only, writes nothing.
npx admin-nav-audit-preferences

# Same run, applying the repairs it listed
npx admin-nav-audit-preferences --fix
ReportedWhat it meansWhat --fix does
foreign-ownerThe row's user points at no document in your admin auth collectionDeletes the row
no-ownerThe row has no user at allDeletes the row
duplicate-ownerSeveral rows claim the same owner — the unique index is not enforced hereNothing. Deleting the wrong twin destroys a real layout; decide by hand
layout-rejectedNothing in navLayout.groups survives the read-side check: that user silently gets the default navClears navLayout
layout-filteredWhat the row stores is not what renders — entries or keys are dropped on the way outRewrites navLayout.groups to what already renders
layout-invalidThe stored layout is one the current validator refuses, so its owner can no longer save a change to that fieldRewrites it to the sanitized equivalent, or clears it when nothing usable is left
collapsed-invalidcollapsedGroups holds non-strings or is over the capKeeps the valid entries

It runs through the host's own payload CLI, so it picks up your .env and your payload.config.ts. Pass --collection=<slug> if you renamed preferencesSlug, and PAYLOAD_CONFIG_PATH if your config is not where Payload's resolver looks. npx admin-nav-audit-preferences --help lists everything.

Migration from @consilioweb/admin-nav

This package was renamed from @consilioweb/admin-nav to @consilioweb/payload-admin-nav.

Automatic migration (recommended):

npx @consilioweb/migrate

This updates your package.json and all imports automatically.

Manual migration:

npm uninstall @consilioweb/admin-nav
npm install @consilioweb/payload-admin-nav

Then update your imports:

- import { adminNavPlugin } from '@consilioweb/admin-nav'
+ import { adminNavPlugin } from '@consilioweb/payload-admin-nav'

Uninstall

  1. Remove the plugin from your payload.config.ts
  2. Uninstall the package:
pnpm remove @consilioweb/payload-admin-nav
  1. Regenerate the importmap:
pnpm generate:importmap

Data cleanup (optional)

The admin-nav-preferences data stays in your database after uninstall. To remove it:

SQLite:

DROP TABLE IF EXISTS admin_nav_preferences;

PostgreSQL:

DROP TABLE IF EXISTS "admin-nav-preferences" CASCADE;

MongoDB:

db.getCollection('admin-nav-preferences').drop()

Support

License

MIT — ConsilioWEB

Similar plugins