Plugin options
Every option createPuckPlugin accepts, with types and defaults.
createPuckPlugin(options) from @delmaredigital/payload-puck/plugin takes these options. All are optional.
Prop
Type
Detail for each group of options is on its own page: access defaults, layouts, theme, editorStylesheets, pageTreeIntegration, rootPropsMapping and ai.
What the plugin registers
- The
puck-templatescollection, always, unless one already exists. - The
puck-ai-promptsandpuck-ai-contextcollections, whenai.enabledandai.promptsCollection/ai.contextCollectionare set. - The pages collection (or Puck fields on your existing one), when
autoGenerateCollectionis true. - Endpoints under
/api/puck/::collection(GET, POST),:collection/:id(GET, PATCH, DELETE),:collection/:id/versions(GET) and:collection/:id/restore(POST); plusai(POST),ai-promptsandai-context(GET, POST, and PATCH, DELETE by:id) when AI is enabled. - The
puckEditoradmin view.
You can use the plugin more than once, for several page collections. Each call adds its collection to the shared endpoints.
admin
Prop
Type
previewUrl
// Static prefix
createPuckPlugin({
previewUrl: '/preview',
})
// Prefix from page data
createPuckPlugin({
previewUrl: (page) => `/${page.slug || ''}`,
})
// Organization-scoped pages (multi-tenant)
createPuckPlugin({
previewUrl: (page) => {
const orgSlug = page.organization?.slug || 'default'
return (slug) => slug ? `/${orgSlug}/${slug}` : `/${orgSlug}`
},
})When previewUrl is a function, the page document is fetched with depth: 1, so relationship fields are populated.
The editor view is a server component, and functions can't be passed to the client. So the server calls your function with the page document; if the result is itself a function, it calls that with '' to get the base prefix, and sends the prefix to the client, which rebuilds the URL. A returned function must return just the prefix when called with an empty slug, as the multi-tenant example does.

