WLF-Studios

payload nested docs page tree

by WLF-Studios
Admin customization
v3
^3.81.0 || ^3.82.0
MIT

Overview

Summary generated from the README

Adds a hierarchical page tree to the Payload admin list view for collections managed by the nested docs plugin. Editors can reorder siblings or move pages between parents by drag and drop, see publication status badges, and follow live or preview links. It must be registered after the nested docs plugin and was tested with Payload 3.81 and Next.js 16.2.

Features

  • Tree list view with hierarchy, page URL paths and a homepage icon
  • Drag and drop to reorder siblings or move pages between parents
  • Status badges for published, changed and draft pages with custom labels and colors
  • Per-locale status badges that open the editor in that language
  • Live and preview links from badges, including async callbacks for tenant domains
  • Diagnostics logging and a fast mode for narrower list queries

Use cases

  • Restructure a large website page hierarchy visually instead of editing parent fields one by one
  • Review which translations of each page are published, drafted or changed
  • Stage page moves as drafts and publish them later without triggering unwanted deploy hooks

From the author

Page tree plugin for Payload nested docs collections

Installation

npm i payload-nested-docs-page-tree

35

Stars

2

Forks

0

Open Issues

1 months ago

Last Updated

1.7k

Weekly Downloads

v1.6.9

npm Version

591.9 KB

Unpacked Size

2

Dependencies

GitHub stars

35+14 since Sep 6

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

2.1K+1K since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 20262,074
Dec 4, 20262,234
Dec 3, 20262,183
Dec 2, 20262,209
Dec 1, 20262,212
Nov 30, 20262,058
Nov 29, 20261,982
Nov 28, 20261,681
Nov 27, 20261,458
Nov 26, 20261,344
Nov 25, 20261,259
Nov 24, 20261,290
Nov 23, 20261,289
Nov 22, 20261,096
Nov 21, 20261,043
Nov 20, 20261,171
Nov 19, 20261,235
Nov 18, 20261,310
Nov 17, 20261,274
Nov 16, 20261,293
Nov 15, 20261,412
Nov 14, 20261,661
Nov 13, 20261,660
Nov 12, 20261,640
Nov 11, 20261,598
Nov 10, 20261,709
Nov 9, 20261,767
Nov 8, 20261,752
Nov 7, 20261,722
Nov 6, 20261,798
Nov 5, 20261,882
Nov 4, 20261,945
Nov 3, 20261,870
Nov 2, 20262,167
Nov 1, 20262,118
Oct 31, 20262,062
Oct 30, 20262,000
Oct 29, 20261,676
Oct 28, 20261,319
Oct 27, 20261,317
Oct 26, 2026998
Oct 25, 20261,055
Oct 24, 20261,148
Oct 23, 2026863
Oct 22, 20261,066
Oct 21, 20261,293
Oct 20, 20261,274
Oct 19, 20261,346
Oct 18, 20261,429
Oct 17, 20261,190
Oct 16, 20261,366
Oct 15, 20261,459
Oct 14, 20261,449
Oct 13, 20261,480
Oct 12, 20261,443
Oct 11, 20261,418
Oct 10, 20261,447
Oct 9, 20261,466
Oct 8, 20261,505
Oct 7, 20261,610
Oct 6, 20261,716
Oct 5, 20261,752
Oct 4, 20262,125
Oct 3, 20262,134
Oct 2, 20262,103
Oct 1, 20261,907
Sep 30, 20261,696
Sep 29, 20261,544
Sep 28, 20261,388
Sep 27, 2026847
Sep 26, 2026803
Sep 25, 2026804
Sep 24, 2026802
Sep 23, 2026867
Sep 22, 2026892
Sep 21, 2026944
Sep 20, 20261,088
Sep 19, 20261,109
Sep 18, 20261,175
Sep 17, 20261,308
Sep 16, 20261,512
Sep 15, 20261,480
Sep 14, 20261,477
Sep 13, 20261,350
Sep 12, 20261,444
Sep 11, 20261,453
Sep 10, 20261,313
Sep 9, 20261,070
Sep 8, 20261,103
Sep 7, 20261,101
Sep 6, 20261,040

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

Health Score

77/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/1215445841-root.svg)](https://payloaddirectory.dev/plugins/1215445841-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1215445841-root"><img src="https://payloaddirectory.dev/badge/1215445841-root.svg" alt="Payload Directory"></a>
Updated Nov 5, 2026Created Apr 19, 2026Published Nov 5, 2026

README

payload-nested-docs-page-tree

Page management tools for Payload admin, built on @payloadcms/plugin-nested-docs.

  • Page tree UI with hierarchy and page URL paths.
  • Intuitive drag and drop to reorder siblings or move pages between parents.
  • Status badges for published pages, drafts, and drafts with unpublished changes.
  • Localized status badges to see each language's publication status and open the page editor in that language with one click.
  • Live and preview links from badges, with separate destinations for changed pages.
  • Customizable badges with label and color overrides for light and dark themes.
  • Homepage icon to identify the root home page.
  • Publishing controls to stage hierarchy changes or publish eligible moves immediately.
  • Child validation errors identify the invalid page, ID, locale, and field messages when a parent save resaves descendants.
  • Diagnostics mode to trace moves, reorders, and published-state changes.
  • Native list tools including sorting, filters, pagination, bulk selection, and row actions.

Coming soon: custom badges for any cell.

Page tree · Drag and drop · Badges · Localized status · Live and preview links · Homepage icon · Diagnostics · Full setup · Configuration

Page tree UI

Page tree admin overview

Browse nested pages while keeping Payload's sorting, filters, pagination, bulk selection, and row actions.

Branches start expanded when there is no saved state. Expanded rows are remembered in your browser's localStorage per collection and user, including after opening a page, refreshing, sorting, paginating, or searching. No extra configuration is needed.

Visual hierarchy

Hierarchy UI

Page URL paths

Page URL path preview

Drag and drop

Reorder siblings

Requires Payload orderable and sorting by its order field. Drag the reorder handle within the same parent or root level; only the order key changes.

Edit hierarchy

Enable Edit Hierarchy to move pages between parents using Payload's API and nested docs hooks.

Move to a parent

Drop a page onto another page to make it a child.

Move back to root

Drop between root pages to return a page to the root level.

Same-parent reorder guard

Reordering stays within the current parent. Use Edit Hierarchy to change parents.

Moves are staged as drafts by default. Set publishOnMove: true to publish a move immediately only when the page has no pending edits. Collections without drafts always move live.

Publishing and locales

Publishing moves

  • Staged moves update the tree immediately; live paths change on publication.
  • With publishOnMove: true, pages with pending edits still stay staged. Publishing a move also republishes descendants so their live URLs follow the new parent.
  • On localized collections, the parent is shared but breadcrumbs are localized. Publishing a move updates breadcrumbs only in the active locale; other locales retain their previous URLs until published. Leave publishOnMove off if this does not suit your routing.

Drag-And-Drop Is Triggering A Deploy?

If your afterChange hook triggers external work-deploys, notifications, or search indexing-skip tree writes that leave the published site unchanged:

import { pageTreeMoveContextKey } from 'payload-nested-docs-page-tree'

// At the start of your afterChange hook:
if (req.context?.[pageTreeMoveContextKey]) return
Tree operationHook with this guard
Sibling reorder or staged moveSkipped
Published moveRuns once for the subtree

The same guard works with or without publishOnMove. Without it, your hook may run on every drag, including staged changes. Hooks that only invalidate caches generally need no deploy guard.

See the playground deploy hook for a complete example. The plugin provides POST /:id/move and POST /:id/reorder endpoints for these interactions.

Badges

Custom status badges

StateMeaning
publishedPublished and up to date
changedDraft with a published version
draftNot published

Override any labels or colors with badges. Unspecified values use Payload defaults; custom colors adapt to light and dark themes.

Locale status badges

Localized page status badges for English, French, and German, with French selected

See each page's publication status across languages directly in the page tree. Each language has its own color-coded badge showing whether the page is published, a draft, or has unpublished changes. Click a language badge to open that page's editor in the selected language, in the same tab.

The active language also shows its status label, such as FR · Published or FR · Changed. Other languages show their codes, such as EN and DE, with their own status colors. Badges line up across rows so editors can quickly scan for translations that need attention.

Set badges.locales: true to show one badge for each available locale:

nestedDocsPageTreePlugin({
  collections: ['pages'],
  badges: {
    locales: true,
    // Existing colors and labels apply independently to each status.
    labels: { changed: 'Unpublished edits' },
  },
})

For an editor using French, the badges appear side by side: EN | FR · Unpublished edits | DE.

Locale codes display in uppercase and follow the order in Payload's localization configuration, respecting filterAvailableLocales. Existing badge label and color overrides apply to each locale's status.

Badge links support keyboard navigation, include the language and status in their accessible names, and respect your configured admin route. Hidden badges preserve their aligned slots and cannot be clicked. Locale badges link to the editor independently of badgesLinks, which controls live and preview links on single status badges.

This requires Payload's native localized status, configured separately:

// Main Payload config
experimental: { localizeStatus: true },
localization: {
  defaultLocale: 'en',
  locales: ['en', 'fr', 'de'],
},

// Target collection
versions: {
  drafts: { localizeStatus: true },
},

Localized status is experimental in the supported Payload versions. Follow Payload's status-localization and migration guidance before enabling it for existing data. The plugin does not enable it or migrate your database. Collections without localized status, or with badges.locales omitted, retain the existing single badge.

Statuses are read from the latest draft and current document, with locale fallback disabled:

Latest locale statusCurrent locale statusBadge
PublishedAnyPublished
DraftPublishedUnpublished edits
DraftDraft or missingDraft
Missing or unsupportedAnyUnknown (neutral)

The plugin batches the two status reads across the tree result, respects read permissions, and does not fetch content separately for every badge.

Custom appearance

The plugin keeps the status calculation and layout reusable. Use these styling hooks to apply a project-specific appearance, such as seasonal colors and status icons:

  • .pages-hierarchy-locale-statuses: the badge group.
  • .pages-hierarchy-locale-status-badge: a badge, with data-locale, data-status, and data-active.
  • .pages-hierarchy-locale-status-badge__code, __separator, and __label: the visible pieces.

For example, local admin CSS can assign a season color:

.pages-hierarchy-locale-statuses .pages-hierarchy-locale-status-badge[data-locale='summer'] {
  background: #fff0a8;
  color: #594600;
}

A reskin can hide __code and __separator and add a status icon using the badge's ::before and data-status, keeping the active status label and accessible name. The default plugin supplies no icons.

Enable badgesLinks as shown in Setup.

Published badges open live with a right-side link icon; draft-only badges open preview with a right-side eye icon. Because drafts with a published version has two (live and draft) states, choose:

ValueBehavior
'live'Whole badge, including the right-side link icon, opens live
'preview'Whole badge, including the right-side eye icon, opens preview
'both' (default)Body with link icon opens live; eye icon after a separator opens preview
  • Live: A string liveURL is the base URL for the published document's last breadcrumb path. Alternatively, pass a sync or async callback returning the final URL for tenant domains or localized routes. Omit liveURL for preview links only.
  • Preview: Uses the collection's admin.preview callback. Your frontend must serve draft content.

All live and preview links open in new tabs. Unlinked badges have no icon. Omit badgesLinks to keep single status badges unlinked, even with preview configured. Locale badges still link to the editor.

badgesLinks.showIcons defaults to true: live links use Payload's chain-link LinkIcon, and preview links use EyeIcon. Set it to false to hide inline badge icons; in 'both' mode, the separate preview action still shows ExternalLinkIcon after the separator.

For example, with a tenant relationship on pages and a domain field on tenants:

badgesLinks: {
  liveURL: async ({ doc, locale, path, req }) => {
    if (!path || (typeof doc.tenant !== 'string' && typeof doc.tenant !== 'number')) {
      return null
    }

    const tenant = await req.payload.findByID({
      collection: 'tenants',
      id: doc.tenant,
      overrideAccess: false,
      req,
    })

    return new URL(`${locale ? `/${locale}` : ''}${path}`, `https://${tenant.domain}`).href
  },
},

The callback receives { collectionSlug, doc, locale, path, req }. doc is the readable published document at depth 0, so relationships contain IDs. locale is the selected admin locale, or undefined without localization. path is the last published breadcrumb URL from breadcrumbsFieldSlug, or undefined when unavailable. The callback can build its own route without breadcrumbs. It runs only when a live destination is needed and a readable published document exists, and stays on the server. The PageTreeLiveURL type is exported for standalone callbacks.

URL resolution and unavailable links

String live links use breadcrumbsFieldSlug and the published path, unaffected by draft slug or parent changes. Callback results are used as final URLs without appending the breadcrumb path. Relative callback URLs resolve against the CMS request URL; return an absolute URL for a separate frontend. Only HTTP and HTTPS links are accepted. Preview receives the latest saved draft, locale, request, and user token. Unsaved changes and admin.livePreview.url are not used.

Missing breadcrumbs for string live URLs, missing or invalid URLs, or a failing live or preview callback disable only that link. Return null, undefined, or an empty string from the live callback to leave the live destination unlinked. In 'both' mode, no live URL leaves the body as text; no preview URL hides the icon. Single-link modes never switch destinations. The selected mode is independent of the badge label.

Homepage icon

Homepage icon

The homepage icon marks a root page with slug home. For custom collection slugs, use homeIndicator: { collections: ['page-tree'] }.

Diagnostics

Diagnostics logs

Set diagnostics: true and reproduce the issue. Logs group related events by flow and show before/after changes to status, parent, order, and the published row. Diagnostics adds database reads; enable it while investigating.

Log fields and custom logger

Events are tagged [payload-nested-docs-page-tree] and identify the move, reorder, or change-hook step. Key fields:

  • flow: shared ID for one operation.
  • publishedMainRowBefore / publishedMainRowAfter: published-row snapshots (draft: false).
  • before / after / changed: projected status, parent, and order diffs.

A published row losing its published status produces a page-tree-change:status-flip warning.

diagnostics: {
  enabled: true,
  logger: (event) => console.log(event), // send to your preferred logger
},

Setup

Tested with Payload 3.81 and Next.js 16.2. Requires @payloadcms/plugin-nested-docs, which continues to own persistence and breadcrumb generation; your frontend owns routing.

pnpm add payload-nested-docs-page-tree

Register it after your existing nested docs plugin. This example shows every page-tree option, including optional badge styling and links:

import { nestedDocsPlugin } from '@payloadcms/plugin-nested-docs'
import { nestedDocsPageTreePlugin } from 'payload-nested-docs-page-tree'

export const plugins = [
  nestedDocsPlugin({ // Register first; keep your existing nested docs options.
    collections: ['pages'],
  }),
  nestedDocsPageTreePlugin({
    collections: ['pages'], // Required: collections to show as a tree.
    defaultLimit: 100, // Documents per list page.
    hideBreadcrumbs: true, // False to show the read-only breadcrumbs field.
    disabled: false, // True to disable the plugin.

    homeIndicator: { collections: ['pages'] }, // Mark the root "home" page; false disables it.

    badges: { // Omit to use Payload defaults.
      labels: { // Override any status label.
        published: 'Live',
        changed: 'Has Changes', // A draft with a published version.
        draft: 'Draft',
      },
      colors: { // Base colors adapt to light and dark themes.
        published: '#bbf3b0',
        changed: '#b9eaf3',
        draft: '#f8d5a7',
      },
    },

    badgesLinks: { // Omit to disable links; preview uses collection admin.preview.
      showIcons: true, // Default; false hides inline icons and keeps the split preview action.
      draftHasPublishedVersion: 'both', // 'live' | 'preview' | 'both'
      liveURL: 'https://www.example.com', // Base URL for the published breadcrumb path.
    },

    publishOnMove: false, // True publishes moves only for pages without pending edits.
    diagnostics: false, // True to trace moves, reorders, and status changes.
  }),
]

Only collections is required in the page-tree config. Omit badges for default styling and badgesLinks to disable live and preview links. Preview links require the collection's admin.preview callback.

Each target collection needs parent, breadcrumbs, and admin.useAsTitle fields stored at the document's top level. Presentational tabs, rows, collapsibles, and unnamed groups are supported; fields inside named tabs or groups are not.

Refresh the admin import map:

pnpm exec payload generate:importmap

Configuration

OptionDefaultPurpose
collectionsRequiredTarget collection slugs
parentFieldSlug'parent'Nested docs parent field
breadcrumbsFieldSlug'breadcrumbs'Nested docs breadcrumbs field
defaultLimit100List page size
hideBreadcrumbstrueHide the read-only breadcrumbs field
homeIndicator{ collections: ['pages'] }Collections showing a home icon; false disables it
badgesPayload defaultsStatus labels, colors, and optional locale badges
badgesLinksDisabledLive and preview links
publishOnMovefalsePublish moves for pages without pending edits
diagnosticsfalseStructured operation logs
disabledfalseDisable the plugin

Development

Local playground, checks, and release validation

Source lives in src/; the playground lives in dev/.

pnpm install
pnpm dev

Open localhost:3000/admin. The playground creates [email protected] / password on startup. Use seed the database on the dashboard to add sample pages.

The Seed button populates three collections: Pages and Tabbed Pages use shared publication status; Localized Pages uses independent English/French/German status (en, fr, de, in that order). All three use the same 30-page tree, titles, slugs, and ordering in every language. Localized Pages includes mixed published, changed, and draft statuses for testing. Restart the playground after changing locale configuration, then click seed the database to populate all three languages. Reseeding replaces all content and version history in these three playground collections, removing stale pages and restoring the shared demo hierarchy. Users are preserved.

For a fresh in-memory playground database on Windows:

$env:PAYLOAD_TEST_DATABASE = 'true'
pnpm.cmd dev

Without that flag, normal development uses DATABASE_URL from dev/.env. The two status modes can coexist in either database setup; no migration is needed for the new Localized Pages collection.

pnpm generate:types
pnpm generate:importmap
pnpm test:int
pnpm exec tsc --noEmit

For release validation, test the packed artifact in a consumer project:

pnpm build
pnpm pack
# In the consumer project:
pnpm add /path/payload-nested-docs-page-tree-*.tgz

Locale badge visibility

With localized status badges enabled, the optional top-level localeBadgeVisibility: ({ doc, publishedDoc, locale, req }) => boolean callback decides which badges are visible. It runs only on the server and receives the latest draft as doc and the current document as publishedDoc when readable. Both contain all locales and respect the current user's read access. Check each locale's status before treating current content as published. This lets visibility follow published content independently of pending draft changes. Returning false hides the badge from both sight and assistive technology while preserving its aligned slot, including when that locale is selected. Publication status is unchanged.

Without a callback, all locale badges remain visible. When configured, the existing two batched queries read the draft and current document content needed by the callback; no per-row queries are added. The callback and document content are not passed to the client. Project-specific inheritance or detachment rules belong in the consuming app.

The optional top-level localeBadgeStatus: ({ doc, publishedDoc, locale, req, status }) => status callback overrides the displayed status. It receives the latest draft, the current document (when readable), and the default computed status. Both documents contain all locales. Check the current document's locale status before treating its content as published. This callback loads content in the same two access-controlled batched queries; no document content or callbacks are passed to the client. It never writes publication state. Without it, the plugin's normal status behavior is unchanged.

The status callback can also return { status, label } to override one locale's display text while retaining its publication status and status color. The label is used in the badge's accessible name and, for the active locale, its visible text. The resolved label is also exposed as data-label for custom styling. Existing callbacks returning a status string continue to work.

Return { status, marker: { id, label } } (with or without label) to flag a locale without changing its text or color. The plugin draws nothing for it: id is exposed as data-marker for custom styling, and label becomes the badge's title and is appended to its accessible name.

List query performance

Use fastMode as the single switch for narrower page-tree and status queries:

nestedDocsPageTreePlugin({
  collections: ['pages'],
  fastMode: true,
})

With fastMode: true, tree queries select active columns plus the title, parent, breadcrumbs, slug, status, ordering, and effective sort fields. Status queries select id and _status, plus breadcrumbs when needed for live links.

For ordinary lists, fast mode reuses Payload's current rows. When all matching rows are loaded, it reads only missing hierarchy and sort fields with the current user's permissions. For paginated lists, it still loads the full hierarchy so collapsing branches can fill the visible page, but renders only rows whose native cells are unavailable. Cells are matched by document ID. Lists using ordinary text, date, number, email, textarea, checkbox, or code columns send data instead of server-rendered cells and use Payload's RenderDefaultCell for visible rows only. Locale status and missing-metadata reads run concurrently when the native list already provides all matching IDs.

Custom cells, rich text cells, custom document URLs, and hidden title columns use the tree renderer so they receive enriched row data. Base filters, grouped/trash views, and badge link configuration retain the full query/rendering path. This does not bypass Payload's own list loading or version-status enrichment.

If custom cells, hooks, localeBadgeStatus, or localeBadgeVisibility read extra fields, include them in the collection's native Payload forceSelect. Preview and live URL callbacks retain full documents so their links continue to work.

With fastMode: false (the default), the plugin reads full documents for tree and status queries, even when admin.enableListViewSelectAPI is enabled.

Similar plugins