@innovixx/payload-next-cache-revalidate-plugin
v0.1.1
Published
plugin for Payload CMS that calls Next.js revalidation endpoints to clear the server-side cache, ensuring that users receive the most up-to-date content.
Downloads
4
Readme
Payload Next Cache Revalidate Plugin
A plugin for https://github.com/payloadcms/payload that calls Next.js revalidation endpoints to clear the server-side cache, ensuring that users receive the most up-to-date content.
Core Features:
- Revalidate cache for specified collections
- Supports dynamic URL generation for revalidation endpoints
Installation
pnpm add @innovixx/payload-next-cache-revalidate-plugin
# OR
npm i @innovixx/payload-next-cache-revalidate-pluginBasic Usage
import { payloadNextCacheRevalidatePlugin } from '@innovixx/payload-next-cache-revalidate-plugin';
const payloadConfig = {
...
plugins: [
payloadNextCacheRevalidatePlugin({
collections: [
'page',
],
generateUrl: async ({ doc, collectionConfig, req }) => {
switch (collectionConfig.slug) {
default:
case 'page': {
return `${process.env.CLIENT_URL}/revalidate?path=/${doc.slug}`;
}
}
},
}),
],
...
};Development
To actively develop or debug this plugin, you can either work directly within the demo directory of this repo or link your own project.
Internal Demo
This repo includes a fully working, self-seeding instance of Payload that installs the plugin directly from the source code. This is the easiest way to get started. To spin up this demo, follow these steps:
- First, clone the repo
cd YOUR_PLUGIN_REPO && pnpm && pnpm watchcd YOUR_PLUGIN_REPO/demo && pnpm && pnpm cleanDev- Now open
http://localhost:3000/adminin your browser - Enter username
[email protected]and passwordPa$$w0rd!
That's it! Changes made in ./src will be reflected in your demo.
