@delmaredigital/payload-puck

中文文档
0.11.0发布于 2026/11/09MITTypeScriptES Module构建来源已验证近 30 天下载 6789

Puck visual page builder plugin for Payload CMS

原始使用文档
文档目录11 节
  1. Documentation
  2. Install
  3. Requirements
  4. Quick Start
  5. 1. Add the Plugin
  6. 2. Provide Puck Configuration
  7. 3. Create a Frontend Route
  8. Documentation
  9. Integrations
  10. Running experiments on slots
  11. License

@delmaredigital/payload-puck

A PayloadCMS plugin for integrating Puck visual page builder. Build pages visually with drag-and-drop components while leveraging Payload's content management capabilities.

Starter Template - Use This

Deploy with Vercel

Documentation: plugins.delmaredigital.com/docs/puck · Overview

⚠️ Upgrading to 0.10.x from 0.9? Breaking — requires @puckeditor/core 0.24. Run pnpm add @puckeditor/core@^0.24.0. The built-in components now arrange their sidebar fields in General / Style / Layout tabs, and the action bar shows a drag handle (dnd={{ enableDragHandle: false }} on PuckEditor hides it). Saved page data is unchanged. 0.10.1 only raises dependency floors. 0.10.2 is a security fix — upgrade recommended: the admin editor view now applies the collection's read access. It also makes the admin editor full-screen, and the canvas no longer inherits the admin page's CSS; list any stylesheet your preview needs in editorStylesheets. 0.10.3 adds integrations (bundles of components, categories and editor plugins from other packages); nothing changes if you don't use them. 0.11.0 is a security fix and breaking: anonymous callers can read published pages only (collections with drafts turned off are unaffected), so a preview that reads drafts without a signed-in user must pass one or set access.read; see upgrading. See the CHANGELOG.

Coming from an older version? The Upgrade Guide lists what each breaking or security release needs.


Documentation

Ask DeepWiki

Covers installation, configuration, components, custom fields, theming, layouts, dark mode, page-tree integration, hybrid integration, AI integration, and more.


Install

pnpm add @delmaredigital/payload-puck @puckeditor/core

Requirements

DependencyVersion
node>= 20.9.0
@puckeditor/core>= 0.24.0
payload>= 3.69.0
@payloadcms/next>= 3.69.0
next>= 15.4.8 (see security note below)
react>= 19.2.1

Using @delmaredigital/payload-better-auth? Any published version works — its auth strategy stamps collection on the user, which is what 0.9's access resolution needs. 0.9.0 or later is recommended: it is the first release where the recommended payload.auth() wiring, combined with the request headers 0.9 now forwards into Payload, is free of side effects for API-key requests. Current is 0.11.3, which requires Better Auth 1.7.

Note: Puck 0.21+ moved from @measured/puck to @puckeditor/core. This plugin requires the new package scope.

Security: If your app uses Next.js middleware (or proxy.ts) to protect dynamic routes, use next >= 15.5.16 / 16.2.5 to pick up the fix for CVE-2026-44574 (middleware bypass via dynamic route parameter injection). Turbopack users need >= 15.5.18 / 16.2.6.


Quick Start

1. Add the Plugin

// src/payload.config.ts
import { buildConfig } from 'payload'
import { createPuckPlugin } from '@delmaredigital/payload-puck/plugin'

export default buildConfig({
  plugins: [
    createPuckPlugin({
      pagesCollection: 'pages',
    }),
  ],
})

2. Provide Puck Configuration

// app/(app)/layout.tsx
import { PuckConfigProvider } from '@delmaredigital/payload-puck/client'
import { editorConfig } from '@delmaredigital/payload-puck/config/editor'

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        <PuckConfigProvider config={editorConfig}>
          {children}
        </PuckConfigProvider>
      </body>
    </html>
  )
}

3. Create a Frontend Route

// app/(frontend)/[[...slug]]/page.tsx
import { getPayload } from 'payload'
import config from '@payload-config'
import { PageRenderer } from '@delmaredigital/payload-puck/render'
import { baseConfig } from '@delmaredigital/payload-puck/config'
import { notFound } from 'next/navigation'

async function getPage(slug?: string[]) {
  const payload = await getPayload({ config })
  const slugPath = slug?.join('/') || ''
  const { docs } = await payload.find({
    collection: 'pages',
    where: {
      and: [
        { _status: { equals: 'published' } },
        slugPath
          ? { slug: { equals: slugPath } }
          : { isHomepage: { equals: true } },
      ],
    },
    limit: 1,
  })
  return docs[0] || null
}

export default async function Page({ params }: { params: Promise<{ slug?: string[] }> }) {
  const { slug } = await params
  const page = await getPage(slug)
  if (!page) notFound()
  return <PageRenderer config={baseConfig} data={page.puckData} />
}

That's it! The plugin registers the editor view, API endpoints, and "Edit with Puck" buttons automatically.

Copy starter files from GitHub or the starter files guide. See examples/README.md for the file guide and setup notes. The npm package ships only dist; examples must be copied from GitHub or the docs. Contributors can check them against the source exports with pnpm typecheck:examples.


Documentation

For everything else — components, custom fields, theming, layouts, dark mode, page-tree integration, hybrid integration, AI integration, advanced configuration, and the full export reference — see the full documentation.


Integrations

An integration bundles Puck components, categories and optional editor plugins. Host components and category fields win; integrations fill missing component keys and append category names. Config helpers ignore plugins.

// Render config
import { extendConfig, baseConfig, type PuckIntegration } from '@delmaredigital/payload-puck/config'

const integrations: readonly PuckIntegration[] = [{
  name: 'dummy',
  components: { DummyBlock: { render: () => <div>Dummy block</div> } },
  categories: { custom: { title: 'Custom', components: ['DummyBlock'] } },
}]

export const renderConfig = extendConfig({ base: baseConfig, integrations })
'use client'

import { PuckConfigProvider, type PuckIntegration } from '@delmaredigital/payload-puck/client'
import { editorConfig } from '@delmaredigital/payload-puck/config/editor'
import type { ReactNode } from 'react'

const integrations: readonly PuckIntegration[] = [{
  name: 'dummy',
  components: { DummyBlock: { render: () => <div>Dummy block</div> } },
  categories: { custom: { title: 'Custom', components: ['DummyBlock'] } },
}]

export function EditorProvider({ children }: { children: ReactNode }) {
  return <PuckConfigProvider config={editorConfig} integrations={integrations}>{children}</PuckConfigProvider>
}

Create the integration array once at module scope: a new array per render rebuilds the editor config. PuckEditor also accepts integrations directly. Integration plugins follow prop and context plugins; named integration plugins are deduped against prop, context and earlier integration plugins. plugins={false} disables all plugins while integration components still apply.

The editor applies integrations without exclude, so to opt out of an integration's component, omit that integration from the provider or define your own component under the same key, which wins.

Running experiments on slots

Use @delmaredigital/payload-experiments to run experiments on Puck slots through an integration. Works with: payload-experiments ≥0.4.0 ↔ payload-puck ≥0.10.3.

License

MIT

版本与发布记录

@delmaredigital/payload-puck 共发布 54 个版本,首次发布于 2026/01/09;过去 12 个月发布了 54 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.11.0latest2026/11/092 天前
0.10.32026/11/066 天前
0.10.22026/10/3112 天前
0.10.12026/10/3013 天前
0.10.02026/10/3013 天前
0.9.62026/10/2022 天前

关于 @delmaredigital/payload-puck 的常见问题

@delmaredigital/payload-puck 是什么?

Puck visual page builder plugin for Payload CMS

如何安装 @delmaredigital/payload-puck?

在项目目录运行 npm install @delmaredigital/payload-puck,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:next(>=15.4.8)、react(>=19.2.1)、payload(>=3.69.0)、react-dom(>=19.2.1)、@puckeditor/core(>=0.24.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@delmaredigital/payload-puck 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@delmaredigital/payload-puck 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@delmaredigital/payload-puck 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.9.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@delmaredigital/payload-puck 可以商用吗?

@delmaredigital/payload-puck 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@delmaredigital/payload-puck 的下载量有多少?

根据 npm 官方下载统计,@delmaredigital/payload-puck 在 2026/10/12 – 2026/11/10 这 30 天内被下载 6,789 次,日均约 226 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@delmaredigital/payload-puck 还在维护吗?

最新版本 0.11.0 发布于 2026/11/09(2 天前);至今共发布 54 个版本,其中过去 12 个月发布了 54 个;首次发布于 2026/01/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。