Skip to Content
Delmare Digital
Guides

Plugin order

Register pageTreePlugin after any plugin that creates the collections it manages, such as payload-puck with a generated Pages collection.

The page-tree plugin looks for its collections when it runs. Any plugin that creates one of those collections must come before it in the plugins array.

Using payload-puck

If @delmaredigital/payload-puck generates your Pages collection, put createPuckPlugin() before pageTreePlugin().

Why order matters

Payload runs plugins in array order. When page-tree runs, it checks which of its configured collections exist. A collection that another plugin adds later doesn't exist yet, so page-tree skips it.

src/payload.config.ts
// Correct: Puck creates Pages before page-tree runs
export const plugins = [
  createPuckPlugin({ pagesCollection: 'pages' }), // Creates the Pages collection
  pageTreePlugin({ collections: ['pages'] }),     // Now sees Pages
]

// Wrong: page-tree runs before Pages exists
export const plugins = [
  pageTreePlugin({ collections: ['pages'] }),     // Pages doesn't exist yet
  createPuckPlugin({ pagesCollection: 'pages' }), // Creates Pages too late
]

Symptoms of the wrong order

  • The tree view only shows one collection when you configured several.
  • Double-clicking a page opens the wrong collection.
  • The console shows [payload-page-tree] Collections not found: pages.

When order doesn't matter

If you define your collections yourself rather than letting a plugin generate them, they exist before any plugin runs and the order is free:

src/payload.config.ts
export default buildConfig({
  collections: [Pages, Posts], // Both exist before any plugin runs
  plugins: [
    pageTreePlugin({ collections: ['pages', 'posts'] }),
    createPuckPlugin({
      pagesCollection: 'pages',
      autoGenerateCollection: false,
    }),
  ],
})

When a collection has a puckData field, the tree detects Puck: Edit and double-click open the Puck editor at {adminRoute}/puck-editor/{collection}/{id}, and an extra Edit in Payload action opens the standard edit screen. See the payload-puck docs.

Edit this page on GitHub

On this page