stefgootzen

payload plugin versioning

by stefgootzen
Publishing workflow
v2
^2.0.0
MIT

Overview

Summary generated from the README

Sets up the fields and hooks needed to version documents by relating a base collection to a version collection. It is added through a withVersioning wrapper in the plugins section of the Payload config, with one or more base and version slug pairs. It targets Payload 2.x; 3.x is untested.

Features

  • Adds a versions field on the base collection and a base field on the version collection
  • Deletes a version from its base when the version is removed
  • Deletes all related versions when a base document is deleted
  • Automatically increments a versionNumber field on each version
  • Creates the first version together with the base document in a single request

Use cases

  • Keep several independent versions of a document that are all meant to be published
  • Manage base documents and their numbered versions as separate collections

From the author

PayloadCMS plugin that sets up all necessary fields and hooks to enable collection versioning.

Installation

npm i @stefgootzen/payload-plugin-versioning

2

Stars

0

Forks

2

Open Issues

5 months ago

Last Updated

30

Weekly Downloads

v1.0.2

npm Version

34.8 KB

Unpacked Size

0

Dependencies

GitHub stars

20 since Sep 7

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 20262
Dec 5, 20262
Dec 4, 20262
Dec 3, 20262
Dec 2, 20262
Dec 1, 20262
Nov 30, 20262
Nov 29, 20262
Nov 28, 20262
Nov 27, 20262
Nov 26, 20262
Nov 25, 20262
Nov 24, 20262
Nov 23, 20262
Nov 22, 20262
Nov 21, 20262
Nov 20, 20262
Nov 19, 20262
Nov 18, 20262
Nov 17, 20262
Nov 16, 20262
Nov 15, 20262
Nov 14, 20262
Nov 13, 20262
Nov 12, 20262
Nov 11, 20262
Nov 10, 20262
Nov 9, 20262
Nov 8, 20262
Nov 7, 20262
Nov 6, 20262
Nov 5, 20262
Nov 4, 20262
Nov 3, 20262
Nov 2, 20262
Nov 1, 20262
Oct 31, 20262
Oct 30, 20262
Oct 29, 20262
Oct 28, 20262
Oct 27, 20262
Oct 26, 20262
Oct 25, 20262
Oct 24, 20262
Oct 23, 20262
Oct 22, 20262
Oct 21, 20262
Oct 20, 20262
Oct 19, 20262
Oct 18, 20262
Oct 17, 20262
Oct 16, 20262
Oct 15, 20262
Oct 14, 20262
Oct 13, 20262
Oct 12, 20262
Oct 11, 20262
Oct 10, 20262
Oct 9, 20262
Oct 8, 20262
Oct 7, 20262
Oct 6, 20262
Oct 5, 20262
Oct 4, 20262
Oct 3, 20262
Oct 2, 20262
Oct 1, 20262
Sep 30, 20262
Sep 29, 20262
Sep 28, 20262
Sep 27, 20262
Sep 26, 20262
Sep 25, 20262
Sep 24, 20262
Sep 23, 20262
Sep 22, 20262
Sep 21, 20262
Sep 20, 20262
Sep 19, 20262
Sep 18, 20262
Sep 17, 20262
Sep 16, 20262
Sep 15, 20262
Sep 14, 20262
Sep 13, 20262
Sep 12, 20262
Sep 11, 20262
Sep 10, 20262
Sep 9, 20262
Sep 8, 20262
Sep 7, 20262
npm weekly downloads

31+13 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 202631
Dec 5, 202614
Dec 4, 202615
Dec 3, 202614
Dec 2, 20263
Dec 1, 20264
Nov 30, 20264
Nov 29, 202612
Nov 28, 202611
Nov 27, 202610
Nov 26, 202610
Nov 25, 202611
Nov 24, 202610
Nov 23, 202610
Nov 22, 20263
Nov 21, 20263
Nov 20, 20266
Nov 19, 20267
Nov 18, 20266
Nov 17, 20267
Nov 16, 20268
Nov 15, 20266
Nov 14, 20267
Nov 13, 20266
Nov 12, 20265
Nov 11, 20265
Nov 10, 202612
Nov 9, 202624
Nov 8, 202624
Nov 7, 202623
Nov 6, 202621
Nov 5, 202621
Nov 4, 202621
Nov 3, 202613
Nov 2, 20260
Nov 1, 20260
Oct 31, 20260
Oct 30, 20260
Oct 29, 20260
Oct 28, 20260
Oct 27, 20260
Oct 26, 20260
Oct 25, 20262
Oct 24, 20262
Oct 23, 20262
Oct 22, 20263
Oct 21, 20263
Oct 20, 20264
Oct 19, 20264
Oct 18, 20262
Oct 17, 20262
Oct 16, 20262
Oct 15, 20261
Oct 14, 20261
Oct 13, 20260
Oct 12, 20260
Oct 11, 20261
Oct 10, 20261
Oct 9, 20261
Oct 8, 20269
Oct 7, 20269
Oct 6, 202613
Oct 5, 202615
Oct 4, 202614
Oct 3, 202614
Oct 2, 202614
Oct 1, 20269
Sep 30, 202611
Sep 29, 202617
Sep 28, 202615
Sep 27, 202615
Sep 26, 202618
Sep 25, 202618
Sep 24, 202615
Sep 23, 202613
Sep 22, 20264
Sep 21, 202625
Sep 20, 202625
Sep 19, 202622
Sep 18, 202624
Sep 17, 202625
Sep 16, 202625
Sep 15, 202625
Sep 14, 20264
Sep 13, 20264
Sep 12, 20266
Sep 11, 20266
Sep 10, 20266
Sep 9, 20266
Sep 8, 20267
Sep 7, 202618

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

Health Score

39/100Fair

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/791695968-root.svg)](https://payloaddirectory.dev/plugins/791695968-root)
HTML
<a href="https://payloaddirectory.dev/plugins/791695968-root"><img src="https://payloaddirectory.dev/badge/791695968-root.svg" alt="Payload Directory"></a>
Updated Jul 6, 2026Created Apr 25, 2024Published Sep 8, 2025

README

Payload-Plugin-Versioning

PayloadCMS plugin that sets up all necessary fields and hooks to enable collection versioning.

Installation

  1. Run npm install @stefgootzen/payload-plugin-versioning or yarn add @stefgootzen/payload-plugin-versioning.

  2. Add the following to the plugin section of the payload config. Use your own collections.

 withVersioning({
  enabled: true,
  relations: [
    {
      baseSlug: MyBaseCollection.slug,
      versionSlug: MyVersionCollection.slug,
    },
  ],
})

Payload Compatibility

PayloadPlugin-Versioning
2.xCompatible
3.xUntested

Effects

One-to-many relationship management:

  • Adds versions field (many) on base collection.
  • Adds base field (one) on version collection.

Adds cascade behaviour:

  • On version delete: Deletes version on base.
  • On base delete: Deletes all corresponding versions.

Automatic versioning on versions:

  • Adds an automatically incremented versionNumber field on version.

Utility for easy version creation:

  • Easily create first version on base creation, like:
     axios.post(`${url}/api/base`, {
       ...baseData,
      version: {
         ...versionData
      }
    })
    

Why use this instead of build-in versioning?

Payload's build-in versioning is useful when you've got a concept of a (latest) published document. This plugin is for you if versions are supposed to be "published".

Similar plugins