focusreactive

payload plugin presets

by focusreactive
payload-plugins
Admin customization
v3
^3.90.0
MIT

Overview

Summary generated from the README

Adds a presets collection and a Save as preset action on every block, plus a blocks drawer that lists saved presets for one-click application. Blocks are auto-discovered, so no block or collection changes are needed. It requires Payload 3.90 or later and the companion guard plugin, with access to the presets collection defined in a project access policy file.

Features

  • Save any block's field values as a reusable preset
  • Apply a preset to a block with one click from a custom blocks drawer
  • Auto-discovers blocks without modifying blocks or collections
  • Optional preview images for presets
  • Per-block label and field overrides through presetTypes
  • Built-in English and Spanish translations

Use cases

  • Reuse standard hero or section layouts across pages without rebuilding each block
  • Give editors a curated library of block starting points with preview images
  • Restrict who can view, save and delete presets by role through an access policy

From the author

Presets plugin for Payload CMS - save and apply reusable block configurations

Installation

npm i @focus-reactive/payload-plugin-presets

37

Stars

5

Forks

33

Open Issues

Today

Last Updated

5.3k

Weekly Downloads

v1.0.1

npm Version

271.2 KB

Unpacked Size

2

Dependencies

Repository stars

37+22 since Sep 7

Show data
Repository stars by day (UTC)
DateStars
Dec 6, 202637
Dec 5, 202637
Dec 4, 202637
Dec 3, 202637
Dec 2, 202637
Dec 1, 202636
Nov 30, 202635
Nov 29, 202635
Nov 28, 202634
Nov 27, 202634
Nov 26, 202634
Nov 25, 202634
Nov 24, 202634
Nov 23, 202634
Nov 22, 202634
Nov 21, 202634
Nov 20, 202633
Nov 19, 202632
Nov 18, 202632
Nov 17, 202632
Nov 16, 202632
Nov 15, 202632
Nov 14, 202632
Nov 13, 202632
Nov 12, 202632
Nov 11, 202632
Nov 10, 202632
Nov 9, 202631
Nov 8, 202631
Nov 7, 202631
Nov 6, 202631
Nov 5, 202631
Nov 4, 202630
Nov 3, 202630
Nov 2, 202630
Nov 1, 202630
Oct 31, 202630
Oct 30, 202630
Oct 29, 202630
Oct 28, 202630
Oct 27, 202630
Oct 26, 202630
Oct 25, 202630
Oct 24, 202629
Oct 23, 202629
Oct 22, 202629
Oct 21, 202629
Oct 20, 202629
Oct 19, 202629
Oct 18, 202629
Oct 17, 202627
Oct 16, 202626
Oct 15, 202626
Oct 14, 202626
Oct 13, 202625
Oct 12, 202625
Oct 11, 202625
Oct 10, 202625
Oct 9, 202625
Oct 8, 202625
Oct 7, 202625
Oct 6, 202624
Oct 5, 202624
Oct 4, 202624
Oct 3, 202623
Oct 2, 202622
Oct 1, 202622
Sep 30, 202620
Sep 29, 202620
Sep 28, 202620
Sep 27, 202620
Sep 26, 202619
Sep 25, 202618
Sep 24, 202618
Sep 23, 202618
Sep 22, 202618
Sep 21, 202618
Sep 20, 202618
Sep 19, 202618
Sep 18, 202618
Sep 17, 202618
Sep 16, 202618
Sep 15, 202618
Sep 14, 202618
Sep 13, 202617
Sep 12, 202617
Sep 11, 202617
Sep 10, 202616
Sep 9, 202616
Sep 8, 202616
Sep 7, 202615

Shared by 15 plugins in focusreactive/payload-plugins.

npm weekly downloads

5.3K+4.7K since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 20265,299
Dec 5, 20264,550
Dec 4, 20264,228
Dec 3, 20262,975
Dec 2, 20262,264
Dec 1, 20262,199
Nov 30, 20262,190
Nov 29, 20261,686
Nov 28, 20264,475
Nov 27, 20264,728
Nov 26, 20266,984
Nov 25, 20269,607
Nov 24, 202610,154
Nov 23, 202612,127
Nov 22, 202614,228
Nov 21, 202614,008
Nov 20, 202614,242
Nov 19, 202611,812
Nov 18, 20269,568
Nov 17, 20269,210
Nov 16, 20267,238
Nov 15, 20266,346
Nov 14, 20264,209
Nov 13, 20265,429
Nov 12, 20268,405
Nov 11, 202611,046
Nov 10, 202615,271
Nov 9, 202619,390
Nov 8, 202620,315
Nov 7, 202620,660
Nov 6, 202620,099
Nov 5, 202617,456
Nov 4, 202614,775
Nov 3, 202610,379
Nov 2, 20266,571
Nov 1, 20268,008
Oct 31, 20268,234
Oct 30, 20267,495
Oct 29, 20266,518
Oct 28, 20266,001
Oct 27, 20268,761
Oct 26, 202612,465
Oct 25, 202611,715
Oct 24, 202611,444
Oct 23, 202610,663
Oct 22, 202611,261
Oct 21, 202611,999
Oct 20, 20269,219
Oct 19, 20265,217
Oct 18, 20263,135
Oct 17, 20262,644
Oct 16, 20263,443
Oct 15, 20263,529
Oct 14, 20264,766
Oct 13, 20264,893
Oct 12, 20265,607
Oct 11, 20265,634
Oct 10, 20266,956
Oct 9, 20268,076
Oct 8, 202610,908
Oct 7, 202610,541
Oct 6, 202610,688
Oct 5, 202610,458
Oct 4, 20269,957
Oct 3, 20268,679
Oct 2, 20266,796
Oct 1, 20263,357
Sep 30, 20261,827
Sep 29, 20261,568
Sep 28, 20261,034
Sep 27, 20261,013
Sep 26, 20261,078
Sep 25, 20263,346
Sep 24, 20264,538
Sep 23, 20266,945
Sep 22, 20268,503
Sep 21, 20269,632
Sep 20, 202610,540
Sep 19, 202610,401
Sep 18, 20268,177
Sep 17, 20267,055
Sep 16, 20264,725
Sep 15, 20263,230
Sep 14, 20262,138
Sep 13, 2026938
Sep 12, 2026627
Sep 11, 2026720
Sep 10, 2026705
Sep 9, 2026650
Sep 8, 2026590
Sep 7, 2026554

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

Health Score

78/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/1177993877-payload-plugin-presets.svg)](https://payloaddirectory.dev/plugins/1177993877-payload-plugin-presets)
HTML
<a href="https://payloaddirectory.dev/plugins/1177993877-payload-plugin-presets"><img src="https://payloaddirectory.dev/badge/1177993877-payload-plugin-presets.svg" alt="Payload Directory"></a>
Updated Dec 5, 2026Created Mar 10, 2026Published Dec 4, 2026

README

@focus-reactive/payload-plugin-presets

A plugin for Payload CMS that enables saving and applying reusable block presets in the admin panel.

Features

  • Save block configurations as reusable presets
  • Apply presets to blocks with one click
  • Preview images for presets in admin panel
  • Custom blocks drawer with preset selection
  • Auto-discovers blocks - no block or collection modifications needed
  • Multi-language support (EN/ES)

AI Integration Prompt

Copy and paste this prompt into your AI assistant (Cursor, Claude, etc.) to add the plugin to an existing Payload project.

I want reusable block presets in my Payload CMS v3 admin with
@focus-reactive/payload-plugin-presets. Follow these steps in order, and stop to ask me where a step says so.

## Rules you must follow

- Never write an access rule that admits every logged-in user: no `Boolean(req.user)`, no `() => true`,
  no `({ req }) => !!req.user`. A rule names a role, or it is `nobody`.
- Do not invent roles. Ask me who may use, save and delete presets.
- Write every policy entry by hand in `src/access.policy.ts`, and grant each capability and each
  collection right explicitly to the roles I name. Nothing is open by default.
- When the boot or a request fails, fix the cause or ask me. Never use `anyone`, a looser gate,
  `overrideAccess` or a removed or disabled check to make an error go away.
- Do not add `overrideAccess: true` anywhere, and do not pass `overrides.access` to the plugin.

## How the plugin works

The plugin adds a `presets` collection that stores one block's field values per preset, a "Save as preset"
action on every block, and a blocks drawer that offers the saved presets. Editors save, apply, rename and
delete presets through Payload's own REST API for that collection, so the collection's access in the
project's access policy decides who may do what. The plugin has no capabilities of its own; its policy
entry under `plugins` is empty.

## Step 1: install

pnpm add @focus-reactive/payload-plugin-presets @focus-reactive/payload-plugin-guard

Check that `payload` is 3.90 or later; if it is not, upgrade it first.

## Step 2: ask me about roles

Look at the auth collection named in `admin.user` and the roles it has.
Ask me: "Which roles may see and apply presets?", "Which roles may save and rename presets?" and
"Which roles may delete presets?"
Wait for my answers. Write each answer as a gate in the policy file in step 3.

## Step 3: the access policy file

Open `src/access.policy.ts`, or create it if the project has none, following the guard README
(`defineAccessPolicy`, `gate`, `filter`, `nobody`, `anyone`, checked with `satisfies AccessPolicy<Config>`).
If you create it, every collection and global of the config needs an entry: move each existing
`access` of the project into the file, and ask me for every rule you cannot read from the code.
Add these entries for this plugin:

collections: {
  presets: {
    read: <the gate from my first answer>,
    create: <the gate from my second answer>,
    update: <the gate from my second answer>,
    delete: <the gate from my third answer>,
  },
},
plugins: {
  "presets-plugin": {},
},

## Step 4: register the plugin and wrap the config

// payload.config.ts
import { buildConfig } from 'payload'
import { withAccessPolicy } from '@focus-reactive/payload-plugin-guard'
import { presetsPlugin } from '@focus-reactive/payload-plugin-presets'
import { accessPolicy } from './access.policy'

export default withAccessPolicy(
  accessPolicy,
  buildConfig({
    // ...the existing config
    plugins: [
      presetsPlugin({ access: accessPolicy.plugins['presets-plugin'] }),
    ],
  })
)

Run `pnpm payload generate:importmap` and `pnpm payload generate:types`, and with a SQL adapter create and run a migration.

## Step 5: verify, and show me the output

With the app running, send each request and show me the status code.
Every one of them must be refused. If one succeeds, the policy is wrong: stop and tell me.

1. Anonymous preset creation, expect 403:
   curl -i -X POST http://localhost:3000/api/presets -H 'Content-Type: application/json' -d '{"name":"x","presetBlock":[]}'
2. The same request with the session cookie of a user whose role may not save presets, expect 403.
3. DELETE /api/presets/<id> with the session cookie of a user whose role may not delete presets, expect 403.

Then, as a user who may save presets, use "Save as preset" on a block and check that the preset appears in the blocks drawer.

Installation

pnpm add @focus-reactive/payload-plugin-presets @focus-reactive/payload-plugin-guard

Payload 3.90 or later is required.

Usage

1. Register the Plugin

The plugin is built on @focus-reactive/payload-plugin-guard. Who may see, save and delete presets is written in the project's access policy file, as the access of the presets collection.

// src/access.policy.ts, the entries for this plugin
collections: {
  presets: { read: isStaff, create: isEditor, update: isEditor, delete: isEditor },
},
plugins: {
  "presets-plugin": {},
},
// payload.config.ts
import { withAccessPolicy } from "@focus-reactive/payload-plugin-guard";
import { presetsPlugin } from "@focus-reactive/payload-plugin-presets";
import { accessPolicy } from "./access.policy";

export default withAccessPolicy(
  accessPolicy,
  buildConfig({
    plugins: [presetsPlugin({ access: accessPolicy.plugins["presets-plugin"] })],
  })
);

isStaff and isEditor stand for gates on your own roles; the guard README shows how to write them.

2. Regenerate the Import Map

npx payload generate:importmap
# or: pnpm payload generate:importmap / bunx payload generate:importmap

3. SQL adapters only - run a migration

npx payload migrate:create create_presets
npx payload migrate

Skip if you use the MongoDB adapter.


Configuration

presetsPlugin({
  // Optional: override label or fields for specific block types
  presetTypes: [
    {
      slug: "hero", // must match block.slug exactly
      label: { en: "Hero", es: "Hero" }, // optional, falls back to block.labels.singular
      fields: heroPresetFields, // optional, falls back to block.fields
    },
  ],

  // Optional: defaults shown
  slug: "presets",
  labels: {
    singular: { en: "Preset", es: "Preset" },
    plural: { en: "Presets", es: "Presets" },
  },
  mediaCollection: "media",
  enabled: true,

  // Required: the plugin's entry in your access policy
  access: accessPolicy.plugins["presets-plugin"],

  // Optional: collection overrides; access comes from the policy
  overrides: {
    fields: (defaultFields) => [...defaultFields, customField],
    hooks: {
      beforeChange: [myHook],
    },
    admin: {
      defaultColumns: ["name", "type", "updatedAt"],
    },
  },
});

API Reference

presetsPlugin(options)

Main plugin function. access is required; the other options are optional.

OptionTypeDefaultDescription
access{}requiredaccessPolicy.plugins["presets-plugin"] from your access policy
presetTypesPresetType[][]Per-block overrides for label and fields - both fall back automatically
slugstring'presets'Collection slug for presets
labelsobject-Collection labels
enabledbooleantrueEnable/disable plugin
packageNamestring'@focus-reactive/payload-plugin-presets'Override for component resolution (set to local path for dev without npm)
mediaCollectionstring'media'Media collection for preview images
overridesobject-Collection overrides (fields, hooks, admin)

PresetType

interface PresetType {
  slug: string; // Block slug to target - must match block.slug exactly
  label?: string | { en: string; es?: string }; // Falls back to block.labels.singular or slug
  fields?: Field[]; // Falls back to block.fields automatically
}

Access

The plugin declares no capabilities: saving, applying, renaming and deleting presets are plain reads and writes of the presets collection, made with the user's own rights. The collection's entry in the access policy decides who may do each of them.

  • read: who sees presets in the blocks drawer and in the collection.
  • create and update: who saves and renames presets. "Save as preset" and the create button of the preset picker are shown only to a user with create, and the edit button of a preset in the blocks drawer only to a user with update.
  • delete: who deletes presets from the drawer or the collection. The delete button of a preset in the blocks drawer is shown only to a user with delete, and a delete the server refuses is reported in a toast.

Applying a preset changes only the form of the document being edited; saving that document needs the user's own update right on it. The collection is created through the guard, so it takes no access from the plugin or from overrides, and the boot fails while the policy has no entry for it. access is a required option; pass accessPolicy.plugins["presets-plugin"], which is an empty object.

What the plugin owns

SlugKindWritten byRead by
presets (or slug)collectionyour policy's create, update and deleteyour policy's read

With enabled: false the collection is left out, and so is its policy entry.

Translations

The plugin includes built-in translations for English and Spanish. Keys are under presetsPlugin:

  • presetsPlugin.presetActions.* - Save preset modal
  • presetsPlugin.applyPreset.* - Apply preset messages
  • presetsPlugin.blocksDrawer.* - Blocks drawer labels

Notes

  • The plugin automatically strips internal keys (id, blockType, blockName, experiment) when saving presets
  • Preview images are optional but recommended for better UX in the blocks drawer
  • The plugin also transforms blocks fields inside globals

Migrating from 0.x

1.0 moves the plugin onto @focus-reactive/payload-plugin-guard; Upgrading to the guard explains the model all the plugins share, with a complete example. Every access rule is now written by hand in your project's src/access.policy.ts, and nothing is open by default: an entry you leave out stops the boot, and a capability you do not grant is refused for everyone.

What changes

  • Payload and every @payloadcms/* package 3.90 or later, with the React and Next versions Payload 3.90 requires, Node 22.22 or later, and @focus-reactive/payload-plugin-guard installed next to the plugin.
  • access is a required option; the plugin declares no capabilities, so it is the empty presets-plugin entry of the policy.
  • overrides.access is refused at boot: the rules move into the policy entry for the presets collection. In 0.x a project that left overrides.access out let every logged-in user of any auth collection read, save and delete presets.

Steps

  1. Upgrade payload and every @payloadcms/* package to 3.90 or later, run the server on Node 22.22 or later, and install the guard: pnpm add @focus-reactive/payload-plugin-guard @focus-reactive/payload-plugin-presets.

  2. Add the plugin's entries to src/access.policy.ts, with gates for your own roles; if the project has no policy file yet, write it first as the guide describes.

    // src/access.policy.ts, inside defineAccessPolicy({ ... })
    collections: {
      presets: { create: isEditor, read: panelUser, update: isEditor, delete: isEditor },
    },
    plugins: {
      "presets-plugin": {},
    },
    
    • presets (or the slug in slug): read decides who sees presets in the blocks drawer, create and update who saves and renames them, delete who deletes them.
    • Applying a preset changes only the open form; saving the document still needs the user's own update right on it.
  3. Pass access: accessPolicy.plugins["presets-plugin"] to presetsPlugin, and export the config wrapped: export default withAccessPolicy(accessPolicy, buildConfig({ ... })).

  4. Database: no migration; the presets collection keeps its columns.

  5. Re-test: an anonymous GET /api/presets answers 403, and a user of another auth collection or without create cannot save a preset; then save, apply, rename and delete a preset as an editor.

License

MIT

Similar plugins