VeiaG

payload enhanced sidebar

by VeiaG
Admin customization
v3
v4
^3.75.0
^4.0.0-beta.0 · prerelease

Overview

Summary generated from the README

Replaces the default Payload admin sidebar with a vertical icon tab bar that organizes collections and globals into tabs. Tabs can also act as links, hold custom items, show badges and be hidden per user with server-side access functions. It is configured through the plugin options and requires Payload 3.75 or newer.

Features

  • Icon-based vertical tab bar with Lucide icons or custom icon components
  • Tabs that also navigate through an href while opening their panel
  • Custom navigation items and components merged into groups with position control
  • Badges from collection counts, API endpoints or a reactive provider
  • Server-side access functions to hide tabs, links and items
  • Per-tab sort functions plus cookie or session storage of the active tab

Use cases

  • Organize a large admin into content, e-commerce and settings tabs
  • Show pending order counts as badges next to sidebar entries
  • Hide admin-only sections from non-admin users in the navigation

From the author

An enhanced sidebar plugin for Payload CMS with tabbed navigation to organize collections and globals.

Installation

npm i @veiag/payload-enhanced-sidebar

32

Stars

2

Forks

1

Open Issues

1 weeks ago

Last Updated

784

Weekly Downloads

v0.7.0

npm Version

314.7 KB

Unpacked Size

2

Dependencies

GitHub stars

32+9 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 202632
Dec 4, 202632
Dec 3, 202632
Dec 2, 202632
Dec 1, 202631
Nov 30, 202631
Nov 29, 202631
Nov 28, 202631
Nov 27, 202631
Nov 26, 202631
Nov 25, 202631
Nov 24, 202631
Nov 23, 202631
Nov 22, 202631
Nov 21, 202631
Nov 20, 202631
Nov 19, 202631
Nov 18, 202631
Nov 17, 202631
Nov 16, 202631
Nov 15, 202631
Nov 14, 202631
Nov 13, 202631
Nov 12, 202631
Nov 11, 202631
Nov 10, 202631
Nov 9, 202630
Nov 8, 202630
Nov 7, 202630
Nov 6, 202630
Nov 5, 202630
Nov 4, 202630
Nov 3, 202629
Nov 2, 202629
Nov 1, 202629
Oct 31, 202629
Oct 30, 202629
Oct 29, 202629
Oct 28, 202629
Oct 27, 202629
Oct 26, 202629
Oct 25, 202629
Oct 24, 202629
Oct 23, 202629
Oct 22, 202629
Oct 21, 202629
Oct 20, 202629
Oct 19, 202629
Oct 18, 202629
Oct 17, 202628
Oct 16, 202628
Oct 15, 202628
Oct 14, 202628
Oct 13, 202627
Oct 12, 202626
Oct 11, 202626
Oct 10, 202626
Oct 9, 202625
Oct 8, 202625
Oct 7, 202625
Oct 6, 202625
Oct 5, 202625
Oct 4, 202625
Oct 3, 202625
Oct 2, 202624
Oct 1, 202624
Sep 30, 202624
Sep 29, 202624
Sep 28, 202624
Sep 27, 202624
Sep 26, 202624
Sep 25, 202624
Sep 24, 202624
Sep 23, 202624
Sep 22, 202623
Sep 21, 202623
Sep 20, 202623
Sep 19, 202623
Sep 18, 202623
Sep 17, 202623
Sep 16, 202623
Sep 15, 202623
Sep 14, 202623
Sep 13, 202623
Sep 12, 202623
Sep 11, 202623
Sep 10, 202623
Sep 9, 202623
Sep 8, 202623
Sep 7, 202623
Sep 6, 202623
npm weekly downloads

743+443 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 2026743
Dec 4, 2026706
Dec 3, 2026814
Dec 2, 2026748
Dec 1, 2026809
Nov 30, 2026819
Nov 29, 2026777
Nov 28, 2026978
Nov 27, 20261,094
Nov 26, 2026997
Nov 25, 20261,000
Nov 24, 20261,015
Nov 23, 20261,035
Nov 22, 20261,133
Nov 21, 20261,006
Nov 20, 2026971
Nov 19, 2026982
Nov 18, 20261,029
Nov 17, 2026969
Nov 16, 2026929
Nov 15, 2026871
Nov 14, 2026900
Nov 13, 2026910
Nov 12, 2026917
Nov 11, 2026960
Nov 10, 2026959
Nov 9, 20261,039
Nov 8, 20261,034
Nov 7, 2026998
Nov 6, 2026941
Nov 5, 20261,044
Nov 4, 2026939
Nov 3, 2026909
Nov 2, 2026845
Nov 1, 2026837
Oct 31, 2026841
Oct 30, 2026815
Oct 29, 2026567
Oct 28, 2026451
Oct 27, 2026485
Oct 26, 2026553
Oct 25, 2026590
Oct 24, 2026612
Oct 23, 2026509
Oct 22, 2026617
Oct 21, 2026826
Oct 20, 2026864
Oct 19, 2026965
Oct 18, 2026995
Oct 17, 2026974
Oct 16, 20261,132
Oct 15, 20261,164
Oct 14, 20261,150
Oct 13, 20261,072
Oct 12, 2026871
Oct 11, 2026770
Oct 10, 2026734
Oct 9, 2026722
Oct 8, 2026724
Oct 7, 2026718
Oct 6, 2026722
Oct 5, 2026761
Oct 4, 2026869
Oct 3, 2026899
Oct 2, 20261,130
Oct 1, 20261,381
Sep 30, 20261,355
Sep 29, 20261,385
Sep 28, 20261,355
Sep 27, 20261,311
Sep 26, 20261,305
Sep 25, 20261,195
Sep 24, 2026899
Sep 23, 2026874
Sep 22, 2026837
Sep 21, 2026866
Sep 20, 2026861
Sep 19, 2026955
Sep 18, 2026826
Sep 17, 2026847
Sep 16, 2026845
Sep 15, 2026851
Sep 14, 2026877
Sep 13, 2026848
Sep 12, 2026655
Sep 11, 2026585
Sep 10, 2026556
Sep 9, 2026460
Sep 8, 2026445
Sep 7, 2026371
Sep 6, 2026300

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

Health Score

75/100Excellent

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/1139180096-root.svg)](https://payloaddirectory.dev/plugins/1139180096-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1139180096-root"><img src="https://payloaddirectory.dev/badge/1139180096-root.svg" alt="Payload Directory"></a>
Updated Nov 24, 2026Created Jan 21, 2026Published Oct 27, 2026

README

Payload Enhanced Sidebar

An enhanced sidebar plugin for Payload CMS that adds a tabbed navigation system to organize collections and globals into logical groups.

Features

  • Tabbed Navigation - Organize collections into separate tabs for cleaner navigation
  • Vertical Tab Bar - Icon-based tabs on the left side of the sidebar
  • Link Support - Add navigation links (like Dashboard) alongside tabs, or give a tab its own href so it navigates and opens its panel
  • Custom Items - Add custom navigation items that can be merged into existing groups
  • Badges - Show notification badges on tabs and navigation items (API-based or reactive provider)
  • Custom Components - Replace any part of the sidebar with your own React components
  • i18n Support - Full localization support for labels and groups
  • Lucide Icons - Use any Lucide icon for tabs and links, or provide a custom icon component per tab

Showcase

Installation

npm install @veiag/payload-enhanced-sidebar
# or
yarn add @veiag/payload-enhanced-sidebar
# or
pnpm add @veiag/payload-enhanced-sidebar

Windows support

See this comment if you have issues with scss : https://github.com/VeiaG/payload-enhanced-sidebar/issues/12#issuecomment-4229207755

Quick Start

import { payloadEnhancedSidebar } from '@veiag/payload-enhanced-sidebar'
import { buildConfig } from 'payload'

export default buildConfig({
  // ... your config
  plugins: [
    payloadEnhancedSidebar({
      // Works with defaults!
    }),
  ],
})

This will add:

  • A Dashboard link at the top
  • A default tab showing all collections and globals
  • A logout button at the bottom

Default Config

Configuration

Full Configuration Example

import { payloadEnhancedSidebar } from '@veiag/payload-enhanced-sidebar'
import { buildConfig } from 'payload'

export default buildConfig({
  plugins: [
    payloadEnhancedSidebar({
      // Tabs and links in the sidebar
      tabs: [
        // Dashboard link
        {
          id: 'dashboard',
          type: 'link',
          href: '/',
          icon: 'House',
          label: { en: 'Dashboard', uk: 'Головна' },
        },
        // Content tab - shows specific collections
        {
          id: 'content',
          type: 'tab',
          icon: 'FileText',
          label: { en: 'Content', uk: 'Контент' },
          collections: ['posts', 'pages', 'categories'],
        },
        // Link to external documentation
        {
          id: 'docs',
          type: 'link',
          href: 'https://payloadcms.com/',
          icon: 'BookOpen',
          isExternal: true,
          label: { en: 'Documentation', uk: 'Документація' },
        },
        // E-commerce tab with custom items
        {
          id: 'ecommerce',
          type: 'tab',
          icon: 'ShoppingCart',
          label: { en: 'E-commerce', uk: 'E-commerce' },
          collections: ['products', 'orders', 'customers'],
          customItems: [
            {
              slug: 'analytics',
              href: '/analytics',
              label: { en: 'Analytics', uk: 'Аналітика' },
              group: 'E-commerce', // Merge into existing group
            },
            {
              slug: 'quick-add',
              href: '/quick-add',
              label: { en: 'Quick Add', uk: 'Швидке додавання' },
              position: 'top', // Appears above all collection groups
            },
          ],
        },
        // Settings tab with globals
        {
          id: 'settings',
          type: 'tab',
          icon: 'Settings',
          label: { en: 'Settings', uk: 'Налаштування' },
          collections: ['users'],
          globals: ['site-settings', 'footer-settings'],
          customItems: [
            {
              slug: 'api-keys',
              href: '/api-keys',
              label: { en: 'API Keys', uk: 'API Ключі' },
              // No group - will appear at the bottom
            },
            {
              slug:'external-link',
              href: 'https://example.com',
              isExternal: true,
              label: { en: 'External Link', uk: 'Зовнішнє Посилання'}
            }
          ],
        },
      ],

      // Show/hide logout button (default: true)
      showLogout: true,

      // Remember the active tab per browser tab instead of site-wide (default: 'cookie')
      storage: 'session',

      // Tab to open when nothing is stored (default: first visible tab)
      defaultTab: 'content',

      // Disable the plugin
      disabled: false,
    }),
  ],
})

Configuration Options

tabs

Array of tabs and links to show in the sidebar.

Tab (type: 'tab')

PropertyTypeRequiredDescription
idstringYesUnique identifier
type'tab'YesTab type
iconIconNameYes*Lucide icon name
iconComponentSidebarComponentYes*Path to a custom icon component (string or { path, clientProps })
buttonComponentSidebarComponentNoCustom button for this item only — overrides customComponents.TabButton (see docs)
labelLocalizedStringYesTab tooltip/label
collectionsCollectionSlug[]NoCollections to show in this tab
globalsGlobalSlug[]NoGlobals to show in this tab
customItemsSidebarTabItem[]NoCustom navigation items (see below)
contentComponentSidebarComponentNoReplaces the whole nav area while this tab is active — e.g. a chat list (see docs)
badgeBadgeConfigNoBadge configuration for the tab icon
hrefstringNoMakes the tab navigate as well as open its panel. Relative to the admin route (see below)
position'top' | 'bottom'No'bottom' pins the tab to the bottom of the bar, above the actions (default 'top')
accessTabAccessFunctionNoServer-side access control — return false to hide

* Exactly one of icon or iconComponent is required — they are mutually exclusive. If neither collections nor globals is specified, the tab shows all collections and globals (except tabs with a contentComponent). Once either is set, only the listed slugs are shown — pass collections: [] / globals: [] to show none.

Tabs that are also links (href on a tab)

By default a tab opens a panel and a link navigates — one or the other. Give a tab an href and it does both: a click navigates and opens the tab's panel, so its child items stay visible. This is what you want for a Dashboard tab that should open /admin while still showing its own shortcuts.

tabs: [
  {
    id: 'dashboard',
    type: 'tab',
    href: '/',                 // relative to the admin route → /admin
    icon: 'House',
    label: 'Dashboard',
    customItems: [
      { slug: 'new-post', href: '/collections/posts/create', label: 'New Post' },
    ],
  },
]

Click behavior:

ClickResult
Plain left-clickNavigates to href and opens the tab's panel
⌘ / Ctrl / Shift / Alt click, middle-clickNavigates only — a click that lands in a new tab/window leaves the current window's panel exactly as it was

A tab's href is always relative to the admin route — there is no isExternal here. An external href opens in a new browser tab, which would leave this window untouched and the tab's panel unreachable. Use type: 'link' for external destinations.

The tab renders as a real anchor, so "Open in new tab", link previews and keyboard activation all work as expected.

Such a tab shows two independent states: the background highlight marks the open panel, while the left-edge bar marks the current route — so it stays visible as the active panel even after you navigate away.

Link (type: 'link')

PropertyTypeRequiredDescription
idstringYesUnique identifier
type'link'YesLink type
iconIconNameYes*Lucide icon name
iconComponentSidebarComponentYes*Path to a custom icon component (string or { path, clientProps })
buttonComponentSidebarComponentNoCustom button for this item only — overrides customComponents.TabButton (see docs)
labelLocalizedStringYesLink tooltip/label
hrefstringYesURL
isExternalbooleanNoIf true, href is absolute URL, if not, href is relative to admin route
badgeBadgeConfigNoBadge configuration for the link icon
position'top' | 'bottom'No'bottom' pins the link to the bottom of the bar, above the actions (default 'top')
accessTabAccessFunctionNoServer-side access control — return false to hide

* Exactly one of icon or iconComponent is required — they are mutually exclusive.

Custom slot (type: 'custom')

Renders an arbitrary component in the tabs bar — useful for spacers, separators, decorative elements, etc. Does not open any navigation content.

PropertyTypeRequiredDescription
idstringYesUnique identifier
type'custom'YesCustom slot type
componentSidebarComponentYesComponent to render (string path or { path, clientProps })
position'top' | 'bottom'No'bottom' pins the slot to the bottom of the bar, above the actions (default 'top')
accessTabAccessFunctionNoServer-side access control — return false to hide

The component receives { id } plus any clientProps you pass. See Custom Components for details.

{
  id: 'separator',
  type: 'custom',
  component: './components/Sidebar#TabSeparator',
}

Tab and Link active difference

Tab bar position (position)

Any tab, link, or custom slot can be pinned to the bottom of the tabs bar with position: 'bottom'. Bottom items render in config order, just above the actions area (folders / settings / logout). Items default to 'top'.

tabs: [
  { id: 'dashboard', type: 'link', href: '/', icon: 'House', label: 'Dashboard' },
  { id: 'content', type: 'tab', icon: 'FileText', label: 'Content', collections: ['posts'] },
  // pinned to the bottom, above the logout button
  { id: 'settings', type: 'tab', icon: 'Settings', label: 'Settings', globals: ['site-settings'], position: 'bottom' },
]

The tab bar is not virtualized/scrolled — if you have a very large number of top tabs they may collide with the bottom group. position is intended for a small number of pinned items (settings, help, etc.).

customItems

Custom items can be added to any tab:

{
  slug: 'unique-slug',           // Required: unique identifier
  href: '/path',                 // Required: URL
  label: { en: 'Label' },        // Required: display label
  group: { en: 'Group Name' },   // Optional: merge into existing group or create new
  isExternal: true,              // Optional: if true, href is absolute URL
  position: 'top',               // Optional: 'top' | 'bottom' (default: 'bottom')
}

Group behavior:

  • If group matches an existing collection group label, the item is added to that group
  • If group doesn't match any existing group, a new group is created
  • If group is not specified, the item appears as ungrouped

Position behavior:

  • position: 'top' — item (or new custom group) appears above all collection/global groups
  • position: 'bottom' — appears below all groups (default)
  • Has no effect on items that merge into an existing collection group via group

Custom component item:

Instead of href/label, a custom item can render your own component (slug + component). It renders in the nav row via Payload's component system — both server and client components are supported — and honors the same group/position rules.

{
  slug: 'storage-meter',                       // Required: unique identifier
  component: './components/Sidebar#StorageMeter', // Required: string path or { path, clientProps }
  position: 'top',                             // Optional
  group: 'Content',                            // Optional
}

The component receives CustomNavItemComponentProps ({ slug }) plus any clientProps. See Custom Components for details.

Ordering groups and items (sort)

By default, groups and items follow Payload's default order plus your customItems position/group rules. The sort option lets you take full control of the order per tab, without changing that default for tabs you don't configure.

sort is keyed by tab id. Each entry has two optional functions that return a sort key (number | string | undefined):

payloadEnhancedSidebar({
  tabs: [
    { id: 'shop', type: 'tab', icon: 'ShoppingCart', label: 'Shop', collections: ['products', 'orders'] },
  ],
  sort: {
    shop: {
      // Orders the top-level groups within the tab
      groups: (group, ctx) => {
        // ungrouped items become individual units you can place anywhere
        if (group.isUngrouped && group.entities[0]?.slug === 'banner') return -100
        if (typeof group.label !== 'string' && group.label.en === 'Featured') return 0
        // everything else → default position
      },
      // Orders the entities inside each group
      items: (item, group, ctx) => {
        if (item.type === 'custom-component') return 10 // place after collections
        if (item.slug === 'products') return -10        // pin products first
      },
    },
  },
})

How sort keys work (like CSS order):

  • number — explicit order index; lower comes first.
  • string — sorted lexicographically (localeCompare).
  • undefined — treated as 0, i.e. keeps the default position.

Sorting is stable — anything you don't assign a key to stays where the default logic placed it. Avoid mixing numbers and strings in the same scope (numbers sort before strings).

Notes:

  • Labels are passed raw (not translated) — use group.label.en etc., or translate via ctx.locale.
  • items sorts only within a group — it can't move an item to a different group (use group for that).
  • When a groups function is set, ungrouped items become individual single-item units so you can interleave them between real groups (e.g. a banner above one group, a CTA below another).
  • sort is a final pass that overrides position.
  • Tab bar order (the icons on the left) is simply the order of the tabs array — sort only affects nav content.

Badges

Badges allow you to show notification counts on tabs and navigation items. There are three ways to configure badges:

Add a badge property to any tab or link in the tabs array:

tabs: [
  {
    id: 'orders',
    type: 'tab',
    icon: 'ShoppingCart',
    label: 'Orders',
    collections: ['orders'],
    // Badge on the tab icon
    badge: {
      type: 'collection-count',
      collectionSlug: 'orders',
      color: 'error',
    },
  },
]

Badges on Navigation Items

Use the badges configuration to add badges to any sidebar item (collections, globals, or custom items):

payloadEnhancedSidebar({
  badges: {
    // Show document count for posts collection
    posts: { type: 'collection-count', color: 'primary' },
    // Custom API endpoint
    orders: {
      type: 'api',
      endpoint: '/api/orders/pending',
      responseKey: 'count',
      color: 'error',
    },
    // Provider-based (reactive)
    notifications: { type: 'provider', color: 'warning' },
  },
})

Badge Types

collection-count

Automatically fetches document count from a collection.

{
  type: 'collection-count',
  collectionSlug?: string,  // Defaults to item's slug
  color?: BadgeColor,       // 'default' | 'primary' | 'success' | 'warning' | 'error'
  where?: object,           // Optional filter query
}
api

Fetches badge value from a custom API endpoint.

{
  type: 'api',
  endpoint: string,         // API URL (relative or absolute)
  method?: 'GET' | 'POST',  // Default: 'GET'
  responseKey?: string,     // Key to extract from response. Default: 'count'
  color?: BadgeColor,
}
provider

Uses reactive values from BadgeProvider context. Values update automatically when the provider changes.

{
  type: 'provider',
  slug?: string,            // Key in provider values. Defaults to item's slug/id
  color?: BadgeColor,
}

Using BadgeProvider

For reactive badges (real-time updates, websockets, etc.), use the BadgeProvider:

  1. Create a provider component:
// components/MyBadgeProvider.tsx
'use client'

import { BadgeProvider } from '@veiag/payload-enhanced-sidebar/client'
import { useEffect, useState } from 'react'

export const MyBadgeProvider = ({ children }) => {
  const [counts, setCounts] = useState({
    orders: 0,
    notifications: 0,
  })

  useEffect(() => {
    // Fetch initial counts, subscribe to websocket, etc.
    const ws = new WebSocket('wss://your-api/counts')
    ws.onmessage = (e) => setCounts(JSON.parse(e.data))
    return () => ws.close()
  }, [])

  return <BadgeProvider values={counts}>{children}</BadgeProvider>
}
  1. Add it to Payload's providers:
// payload.config.ts
export default buildConfig({
  admin: {
    components: {
      providers: ['./components/MyBadgeProvider#MyBadgeProvider'],
    },
  },
})
  1. Configure badges to use the provider:
payloadEnhancedSidebar({
  badges: {
    orders: { type: 'provider', color: 'error' },
  },
  tabs: [
    {
      id: 'notifications',
      type: 'link',
      href: '/notifications',
      icon: 'Bell',
      label: 'Notifications',
      badge: { type: 'provider', slug: 'notifications', color: 'warning' },
    },
  ],
})

Badge Colors

Available colors: default, primary, success, warning, error

Badge Colors

Badge Display

  • Numbers up to 99 are shown as-is
  • Numbers > 99 are shown as "99+"
  • Zero or undefined values hide the badge
  • Provider values can also be React nodes for custom rendering

Access Control

You can control visibility of tabs, links, and custom items using an access function. It runs server-side and receives the current PayloadRequest, so you have full access to req.user, roles, permissions, etc.

tabs: [
  {
    id: 'admin-panel',
    type: 'tab',
    icon: 'Shield',
    label: 'Admin',
    collections: ['users', 'tenants'],
    access: ({ req, item }) => {
      return req.user?.role === 'admin'
    },
  },
  {
    id: 'reports',
    type: 'link',
    href: '/reports',
    icon: 'BarChart',
    label: 'Reports',
    access: async ({ req }) => {
      // async is supported
      return Boolean(req.user)
    },
  },
]

If access returns false, the tab button is hidden from the tabs bar and its content is not rendered.

On custom items

customItems: [
  {
    slug: 'admin-tools',
    href: '/admin-tools',
    label: 'Admin Tools',
    access: ({ req }) => req.user?.role === 'admin',
  },
]

Access function signatures:

// For tabs and links
type TabAccessFunction = (args: {
  item: SidebarTab       // full tab/link config
  req: PayloadRequest
}) => boolean | Promise<boolean>

// For custom items
type ItemAccessFunction = (args: {
  item: SidebarTabItem   // full custom item config
  req: PayloadRequest
}) => boolean | Promise<boolean>

Default collections and globals already respect Payload's built-in access control — they are filtered by visibleEntities automatically. The access function is only needed for tabs, links, and custom items.

Behavior when req is unavailable

Access functions are fail-closed: if req is not available (e.g. on certain error pages), all items with an access function will be hidden. This is a known limitation caused by a Payload bug where req is not passed to the Nav component on 404 admin pages.

Custom views and access control

If you have custom admin views, you must pass req to DefaultTemplate for access control to work correctly. Retrieve it from props.initPageResult.req:

import type { AdminViewProps } from 'payload'
import { DefaultTemplate } from '@payloadcms/next/templates'

export async function MyCustomView(props: AdminViewProps) {
  const { initPageResult, params, searchParams } = props
  const { permissions, req, visibleEntities } = initPageResult
  const { i18n, locale, payload, user } = req

  return (
    <DefaultTemplate
      i18n={i18n}
      locale={locale}
      params={params}
      payload={payload}
      permissions={permissions}
      req={req}
      searchParams={searchParams}
      user={user ?? undefined}
      visibleEntities={visibleEntities}
    >
      {/* your view content */}
    </DefaultTemplate>
  )
}

Without req={req}, the sidebar will treat the page as unauthenticated and hide all access-controlled items.

showLogout

Show/hide the logout button at the bottom of the tabs bar.

  • Type: boolean
  • Default: true

disabled

Completely disable the plugin.

  • Type: boolean
  • Default: false

storage

Where the active tab is remembered.

  • Type: 'cookie' | 'session'
  • Default: 'cookie'
ModeBehavior
'cookie'One value for the whole site. Switching tabs in one browser tab changes what the others show after their next navigation or reload.
'session'Each browser tab keeps its own active tab in sessionStorage. Reloads and navigation keep it; a duplicated browser tab starts on the same tab. A new browser tab starts on the last tab picked anywhere, because the cookie is still written. The exception is a tab opened by script with an opener (e.g. window.open without noopener): it gets a copy of the opener's sessionStorage and starts on the opener's tab. Links with target="_blank" open without an opener by default.

The active tab is resolved in this order. A step is skipped when its value isn't a tab the user can see (access changed, a different user, a tab removed from the config):

Step'cookie''session'
1cookiesessionStorage of this browser tab
2defaultTabcookie
3first visible tabdefaultTab
4first visible tab

The server can't see sessionStorage, so in 'session' mode the plugin renders a small inline script at the top of the sidebar. It picks the stored tab before the page is painted, and no wrong panel flashes before hydration. If sessionStorage is blocked (some private modes), the sidebar behaves like 'cookie' mode.

Content Security Policy

If your admin panel uses a nonce-based CSP, 'session' mode needs that nonce for two inline elements: the script (script-src) and a small <style> that shows the active panel (style-src, if your policy restricts styles by nonce). The plugin puts the same nonce on both. Next.js adds the nonce only to its own scripts. The plugin reads it from the request's Content-Security-Policy header, as Next.js does, so the usual middleware setup works without extra config. If your nonce lives elsewhere, pass it with nonce:

payloadEnhancedSidebar({
  storage: 'session',
  nonce: ({ req }) => req.headers.get('x-nonce') ?? undefined,
})

If the script is blocked, nothing breaks: the sidebar first shows the cookie's tab and switches to the stored one after hydration. If the style is blocked, all panels show at once, so allow both.

Custom NavContent

The built-in nav content and tab contentComponent views are covered automatically. A custom NavContent that hides panels with useTabState shows the cookie's tab until hydration. To avoid that in 'session' mode, drop the inline display style and aria-hidden (both follow React state, which is stale until hydration) and mark each panel with data-tab-panel="<tab id>"; the plugin's CSS shows only the active one:

const { isActive } = useTabState(tab.id)
const { storage } = useEnhancedSidebar()

storage === 'session' ? (
  <div data-tab-panel={tab.id}>{tabsContent[tab.id]}</div>
) : (
  <div aria-hidden={!isActive} style={{ display: isActive ? undefined : 'none' }}>
    {tabsContent[tab.id]}
  </div>
)

The active highlight on tab buttons is set by React, so it may briefly point at the cookie's tab before hydration.

defaultTab

The tab to open when nothing is stored, or when the stored tab isn't visible to the user. A function runs on the server for every request, e.g. to pick a tab by role. If it returns a tab the user can't see, or throws, the first visible tab is used.

  • Type: string | ((args: { req: PayloadRequest }) => string | Promise<string>)
  • Default: the first visible tab
payloadEnhancedSidebar({
  defaultTab: ({ req }) => (req.user?.role === 'editor' ? 'content' : 'settings'),
})

Custom Components

You can replace any part of the sidebar with your own React components. The plugin registers them automatically in Payload's import map — no manual import map configuration needed.

payloadEnhancedSidebar({
  customComponents: {
    // Replace individual nav items (collections, globals, custom links)
    NavItem: './components/Sidebar#MyNavItem',
    // Replace group headers
    NavGroup: './components/Sidebar#MyNavGroup',
    // Replace the entire nav scroll area
    NavContent: './components/Sidebar#MyNavContent',
    // Replace every button in the tabs bar (tabs and links)
    TabButton: './components/Sidebar#MyTabButton',
  },
  tabs: [
    {
      id: 'dashboard',
      type: 'link',
      href: '/',
      // Custom icon for just this tab/link (mutually exclusive with `icon`)
      iconComponent: './components/Sidebar#DashboardIcon',
      label: 'Dashboard',
    },
    {
      id: 'chats',
      type: 'tab',
      icon: 'MessagesSquare',
      label: 'Chats',
      // Custom button for just this tab/link (overrides TabButton)
      buttonComponent: './components/Sidebar#ChatsTabButton',
      // Replace the whole nav area while this tab is active
      contentComponent: './components/Sidebar#ChatListPanel',
    },
  ],
})

Custom components can be client or server components. Everything is pre-rendered on the server on each page load — including tabs that aren't open — so fetch lazily in a client component if that matters (see Rendering). The plugin provides hooks to connect them to sidebar state:

HookDescription
useNavItemState(href){ isActive, isCurrentPage } — for custom NavItem
useTabState(id){ isActive } — for custom NavContent or TabButton
useEnhancedSidebar(){ activeTabId, onTabChange } — full tab context

The default building blocks — NavItem, TabButton, NavContentShell, Badge and useBadge — are exported too, so a custom component can wrap them instead of rebuilding badges, tooltips and active states.

→ See docs/custom-components.md for full documentation, prop types, and examples for each slot.

Localization

All labels support localized strings:

label: 'Simple string'
// or
label: {
  en: 'English',
  uk: 'Українська',
  de: 'Deutsch',
}

Payload Features Support

  • Browse by Folder Button - Automatically shows folder view button when Payload folders are enabled (requires Payload v3.41.0+)
  • Settings Menu Items - Integrates with Payload's SettingsMenu components (requires Payload v3.60.0+)
  • beforeNav / afterNav slots - Supports Payload's admin.components.beforeNav and admin.components.afterNav slots (requires Payload v3.75.0+). Both slots are rendered inside the nav content area — beforeNav before beforeNavLinks, afterNav after afterNavLinks.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Issues

Found a bug or have a feature request? Please open an issue on GitHub.

License

MIT © VeiaG


More plugins and Payload resources at PayloadCMS Extensions

Similar plugins