Registers Payload afterOperation and afterChange hooks on configured collections and globals to call your revalidatePath and revalidateTag callbacks. It can probe a URL and trigger a full rebuild when the page returns 404. Requires Payload 3.37 or later and works with Next.js or any custom revalidation callbacks.
Payload CMS plugin for ISR-style path revalidation with optional full rebuild fallback
Installation
npm i @ggaidelevicius/payload-isr3
Stars
0
Forks
0
Open Issues
2 months ago
Last Updated
45
Weekly Downloads
v1.2.1
npm Version
198.1 KB
Unpacked Size
0
Dependencies
30 since Sep 7
| Date | Stars |
|---|---|
| Dec 6, 2026 | 3 |
| Dec 5, 2026 | 3 |
| Dec 4, 2026 | 3 |
| Dec 3, 2026 | 3 |
| Dec 2, 2026 | 3 |
| Dec 1, 2026 | 3 |
| Nov 30, 2026 | 3 |
| Nov 29, 2026 | 3 |
| Nov 28, 2026 | 3 |
| Nov 27, 2026 | 3 |
| Nov 26, 2026 | 3 |
| Nov 25, 2026 | 3 |
| Nov 24, 2026 | 3 |
| Nov 23, 2026 | 3 |
| Nov 22, 2026 | 3 |
| Nov 21, 2026 | 3 |
| Nov 20, 2026 | 3 |
| Nov 19, 2026 | 3 |
| Nov 18, 2026 | 3 |
| Nov 17, 2026 | 3 |
| Nov 16, 2026 | 3 |
| Nov 15, 2026 | 3 |
| Nov 14, 2026 | 3 |
| Nov 13, 2026 | 3 |
| Nov 12, 2026 | 3 |
| Nov 11, 2026 | 3 |
| Nov 10, 2026 | 3 |
| Nov 9, 2026 | 3 |
| Nov 8, 2026 | 3 |
| Nov 7, 2026 | 3 |
| Nov 6, 2026 | 3 |
| Nov 5, 2026 | 3 |
| Nov 4, 2026 | 3 |
| Nov 3, 2026 | 3 |
| Nov 2, 2026 | 3 |
| Nov 1, 2026 | 3 |
| Oct 31, 2026 | 3 |
| Oct 30, 2026 | 3 |
| Oct 29, 2026 | 3 |
| Oct 28, 2026 | 3 |
| Oct 27, 2026 | 3 |
| Oct 26, 2026 | 3 |
| Oct 25, 2026 | 3 |
| Oct 24, 2026 | 3 |
| Oct 23, 2026 | 3 |
| Oct 22, 2026 | 3 |
| Oct 21, 2026 | 3 |
| Oct 20, 2026 | 3 |
| Oct 19, 2026 | 3 |
| Oct 18, 2026 | 3 |
| Oct 17, 2026 | 3 |
| Oct 16, 2026 | 3 |
| Oct 15, 2026 | 3 |
| Oct 14, 2026 | 3 |
| Oct 13, 2026 | 3 |
| Oct 12, 2026 | 3 |
| Oct 11, 2026 | 3 |
| Oct 10, 2026 | 3 |
| Oct 9, 2026 | 3 |
| Oct 8, 2026 | 3 |
| Oct 7, 2026 | 3 |
| Oct 6, 2026 | 3 |
| Oct 5, 2026 | 3 |
| Oct 4, 2026 | 3 |
| Oct 3, 2026 | 3 |
| Oct 2, 2026 | 3 |
| Oct 1, 2026 | 3 |
| Sep 30, 2026 | 3 |
| Sep 29, 2026 | 3 |
| Sep 28, 2026 | 3 |
| Sep 27, 2026 | 3 |
| Sep 26, 2026 | 3 |
| Sep 25, 2026 | 3 |
| Sep 24, 2026 | 3 |
| Sep 23, 2026 | 3 |
| Sep 22, 2026 | 3 |
| Sep 21, 2026 | 3 |
| Sep 20, 2026 | 3 |
| Sep 19, 2026 | 3 |
| Sep 18, 2026 | 3 |
| Sep 17, 2026 | 3 |
| Sep 16, 2026 | 3 |
| Sep 15, 2026 | 3 |
| Sep 14, 2026 | 3 |
| Sep 13, 2026 | 3 |
| Sep 12, 2026 | 3 |
| Sep 11, 2026 | 3 |
| Sep 10, 2026 | 3 |
| Sep 9, 2026 | 3 |
| Sep 8, 2026 | 3 |
| Sep 7, 2026 | 3 |
46+34 since Sep 7
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 46 |
| Dec 5, 2026 | 25 |
| Dec 4, 2026 | 25 |
| Dec 3, 2026 | 24 |
| Dec 2, 2026 | 34 |
| Dec 1, 2026 | 23 |
| Nov 30, 2026 | 23 |
| Nov 29, 2026 | 21 |
| Nov 28, 2026 | 21 |
| Nov 27, 2026 | 23 |
| Nov 26, 2026 | 22 |
| Nov 25, 2026 | 13 |
| Nov 24, 2026 | 12 |
| Nov 23, 2026 | 10 |
| Nov 22, 2026 | 12 |
| Nov 21, 2026 | 9 |
| Nov 20, 2026 | 8 |
| Nov 19, 2026 | 9 |
| Nov 18, 2026 | 28 |
| Nov 17, 2026 | 28 |
| Nov 16, 2026 | 30 |
| Nov 15, 2026 | 28 |
| Nov 14, 2026 | 29 |
| Nov 13, 2026 | 28 |
| Nov 12, 2026 | 29 |
| Nov 11, 2026 | 7 |
| Nov 10, 2026 | 19 |
| Nov 9, 2026 | 18 |
| Nov 8, 2026 | 18 |
| Nov 7, 2026 | 29 |
| Nov 6, 2026 | 28 |
| Nov 5, 2026 | 26 |
| Nov 4, 2026 | 26 |
| Nov 3, 2026 | 17 |
| Nov 2, 2026 | 19 |
| Nov 1, 2026 | 20 |
| Oct 31, 2026 | 11 |
| Oct 30, 2026 | 11 |
| Oct 29, 2026 | 11 |
| Oct 28, 2026 | 11 |
| Oct 27, 2026 | 13 |
| Oct 26, 2026 | 10 |
| Oct 25, 2026 | 11 |
| Oct 24, 2026 | 10 |
| Oct 23, 2026 | 10 |
| Oct 22, 2026 | 15 |
| Oct 21, 2026 | 27 |
| Oct 20, 2026 | 21 |
| Oct 19, 2026 | 25 |
| Oct 18, 2026 | 24 |
| Oct 17, 2026 | 29 |
| Oct 16, 2026 | 34 |
| Oct 15, 2026 | 33 |
| Oct 14, 2026 | 215 |
| Oct 13, 2026 | 215 |
| Oct 12, 2026 | 211 |
| Oct 11, 2026 | 211 |
| Oct 10, 2026 | 205 |
| Oct 9, 2026 | 201 |
| Oct 8, 2026 | 198 |
| Oct 7, 2026 | 5 |
| Oct 6, 2026 | 5 |
| Oct 5, 2026 | 8 |
| Oct 4, 2026 | 7 |
| Oct 3, 2026 | 7 |
| Oct 2, 2026 | 6 |
| Oct 1, 2026 | 7 |
| Sep 30, 2026 | 6 |
| Sep 29, 2026 | 6 |
| Sep 28, 2026 | 5 |
| Sep 27, 2026 | 6 |
| Sep 26, 2026 | 9 |
| Sep 25, 2026 | 9 |
| Sep 24, 2026 | 7 |
| Sep 23, 2026 | 10 |
| Sep 22, 2026 | 11 |
| Sep 21, 2026 | 22 |
| Sep 20, 2026 | 21 |
| Sep 19, 2026 | 17 |
| Sep 18, 2026 | 18 |
| Sep 17, 2026 | 18 |
| Sep 16, 2026 | 16 |
| Sep 15, 2026 | 16 |
| Sep 14, 2026 | 3 |
| Sep 13, 2026 | 4 |
| Sep 12, 2026 | 10 |
| Sep 11, 2026 | 9 |
| Sep 10, 2026 | 9 |
| Sep 9, 2026 | 11 |
| Sep 8, 2026 | 11 |
| Sep 7, 2026 | 12 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1171481351-root)<a href="https://payloaddirectory.dev/plugins/1171481351-root"><img src="https://payloaddirectory.dev/badge/1171481351-root.svg" alt="Payload Directory"></a>README
Payload CMS plugin that revalidates your Next.js cache when documents are published, updated, unpublished, or deleted — by path, by cache tag, or by triggering a full rebuild when route-level invalidation isn't enough.
^3.37.0^18.20.2 || >=20.9.0pnpm add @ggaidelevicius/payload-isr
# or
npm install @ggaidelevicius/payload-isr
The plugin registers Payload afterOperation and afterChange hooks on whichever collections and globals you configure. When a hook fires:
update / updateByID, unpublish.matcher is evaluated first. If it matches, unpublish-specific resolvers fire (falling back to the main resolvers if unpublish-specific ones are not provided), and shouldHandle is not consulted for that operation.shouldHandle decides whether the document should trigger revalidation (default: document has no _status field, or _status === 'published')probeURL is configured and fullRebuild is enabled, the plugin fetches that URL; a 404 triggers the full rebuild path and skips path/tag revalidationrevalidatePath callback; resolved tags are passed to your revalidateTag callbackDelete revalidation is opt-in via onDelete on each collection target. The plugin warns at startup when a collection has update resolvers but no onDelete strategy.
Bulk collection updates invoke guards and resolvers once per successfully updated document. Each callback receives that document as result; the original bulk response, including errors, is returned unchanged to Payload.
The smallest valid configuration — no tags, no full rebuild, one collection:
import { buildConfig } from 'payload'
import { payloadIsr } from '@ggaidelevicius/payload-isr'
import { revalidatePath } from 'next/cache'
export default buildConfig({
plugins: [
payloadIsr({
revalidatePath: (path) => revalidatePath(path),
collections: [
{
slug: 'posts',
pathResolver: ({ result }) => [`/posts/${result.slug}`, '/posts'],
},
],
}),
],
})
import { buildConfig } from 'payload'
import { createPayloadIsrLogger, payloadIsr } from '@ggaidelevicius/payload-isr'
import {
revalidatePath as nextRevalidatePath,
revalidateTag as nextRevalidateTag,
} from 'next/cache'
export default buildConfig({
plugins: [
payloadIsr({
// Emit structured debug traces for every hook/guard/branch decision.
debug: true,
// Prefix relative paths in debug output with this origin so URLs are clickable.
debugURLOrigin: process.env.PUBLIC_APP_URL,
// Logger that filters noisy config-level traces by default.
logger: createPayloadIsrLogger(),
// Called once per resolved path.
// meta.mode is 'site' when a global uses revalidateAllOnChange — use
// Next.js 'layout' scope in that case to revalidate the full layout tree.
revalidatePath: (path, meta) => {
if (meta.mode === 'site') {
return nextRevalidatePath(path, 'layout')
}
return nextRevalidatePath(path)
},
// Optional. Called once per resolved tag. Omit if you don't use cache tags.
revalidateTag: (tag) => nextRevalidateTag(tag, { expire: 0 }),
collections: [
{
slug: 'posts',
// Paths to revalidate when a post is published or updated.
pathResolver: ({ result }) => [`/posts/${result.slug}`, '/posts'],
// URL to probe before deciding whether a full rebuild is needed.
// If this returns 404, fullRebuild.trigger() is called instead of revalidating paths/tags.
probeURL: ({ result }) => `${process.env.PUBLIC_APP_URL}/posts/${result.slug}`,
// Cache tags to invalidate.
tagResolver: ({ result }) => ['posts', `post:${result.id}`],
// onDelete is optional, but without it this target won't revalidate on deletes.
// The plugin emits a startup warning for this misconfiguration.
onDelete: {
pathResolver: ({ id }) => [`/posts/${id}`, '/posts'],
tagResolver: ({ id }) => ['posts', `post:${id}`],
},
},
],
globals: [
{
slug: 'site-settings',
// Revalidate the entire site (calls revalidatePath('/', 'layout') via meta.mode === 'site').
// Cannot be combined with pathResolver on the same target.
revalidateAllOnChange: true,
tagResolver: () => ['site-settings', 'global'],
},
],
fullRebuild: {
// Disable in development to avoid accidentally triggering deploys.
enabled: process.env.NODE_ENV === 'production',
// Fires when a probeURL returns 404 (the default shouldTrigger condition).
trigger: async () => {
await fetch(process.env.REBUILD_WEBHOOK_URL!, { method: 'POST' })
},
},
}),
],
})
payloadIsr({ ... }))| Option | Type | Required | Description |
|---|---|---|---|
revalidatePath | (path, meta) => void | Promise<void> | No* | Called for each resolved path. See Revalidation metadata. |
revalidateTag | (tag, meta?) => void | Promise<void> | No* | Called for each resolved tag. Omit only if you do not use tag-based caching. |
collections | CollectionISRTarget[] | No | Collection revalidation targets. |
globals | GlobalISRTarget[] | No | Global revalidation targets. |
fullRebuild | FullRebuildConfig | No | Full rebuild fallback. See Full rebuild fallback. |
logger | { error, warn, info? } | No | Custom logger. Defaults to console. Use createPayloadIsrLogger() for structured output with built-in filtering. |
debug | boolean | No | Emit structured trace events via logger.info for every hook, guard, and branch decision. |
debugURLOrigin | string | No | Base URL prepended to relative paths in debug output, making logged paths absolute and clickable. |
disabled | boolean | No | Disable the plugin entirely without removing it from config. |
* At least one of revalidatePath or revalidateTag is required.
TypeScript note: callback args in collections and globals are inferred from each target's slug using Payload's generated types. Invalid field access is caught at compile time. Each target requires at least one revalidation strategy at the type level — the compiler will error if a target has no resolver.
| Option | Type | Default | Description |
|---|---|---|---|
slug | string | — | Collection slug. Must match your Payload collection. |
disabled | boolean | false | Skip this target without removing it from config. |
pathResolver | (args) => string[] | — | Returns paths to revalidate when a document is published or updated. |
tagResolver | (args) => string[] | — | Returns cache tags to invalidate. |
referencePathResolver | (args) => string[] | — | Additional paths to revalidate, merged with pathResolver results. Use findReferencingPaths() here to also bust other pages that embed this document. |
referenceTagResolver | (args) => string[] | — | Additional tags to invalidate, merged with tagResolver results. |
probeURL | (args) => string | — | URL to fetch before triggering full rebuild. Required for full rebuild to ever fire on this target. |
operations | string[] | ['create', 'update', 'updateByID'] | Which Payload operations trigger this target. |
shouldHandle | (args) => boolean | Checks _status === 'published' (or no _status field) | Custom gate. Return false to skip revalidation for this operation. |
unpublish | UnpublishConfig | — | Override unpublish detection and/or unpublish-specific path/tag resolvers. |
onDelete | OnDeleteConfig | — | Opt-in delete revalidation. Without this, deletes are skipped for this target and a startup warning is emitted. |
At least one of pathResolver, tagResolver, referencePathResolver, referenceTagResolver, or probeURL is required at the type level.
| Option | Type | Default | Description |
|---|---|---|---|
slug | string | — | Global slug. Must match your Payload global. |
disabled | boolean | false | Skip this target without removing it from config. |
revalidateAllOnChange | boolean | — | Revalidate the entire site on every change. Passes meta.mode === 'site' to revalidatePath. Cannot be combined with pathResolver. |
revalidateAllPath | string | '/' | Path passed to revalidatePath when revalidateAllOnChange is enabled. Must be absolute. |
pathResolver | (args) => string[] | — | Returns targeted paths. Use this when revalidateAllOnChange is too broad. |
tagResolver | (args) => string[] | — | Returns cache tags to invalidate. |
shouldHandle | (args) => boolean | Checks _status === 'published' (or no _status field) | Custom gate. |
probeURL | (args) => string | — | URL to probe before full rebuild decision. |
At least one strategy required: revalidateAllOnChange: true, or at least one of pathResolver, tagResolver, probeURL.
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true when configured | Whether full rebuild is active. Recommended: process.env.NODE_ENV === 'production'. |
probeTimeoutMs | number | 10000 | Maximum probe duration in milliseconds. Must be finite, positive, and at most 2147483647; invalid values warn and use the default. |
trigger | (context) => void | Promise<void> | — | Required. What to call when a rebuild is triggered. |
shouldTrigger | (context) => boolean | context.probeStatus === 404 | Override the condition for triggering. |
trigger receives a FullRebuildContext with: probeStatus, probeURL, reason, scope, slug.
When configured, both revalidatePath and revalidateTag receive a meta argument describing why revalidation is happening.
revalidatePath(path, meta)meta: {
mode: 'path' | 'site' // 'site' only for globals with revalidateAllOnChange
reason: RevalidationReason
scope: 'collection' | 'global'
slug: string
}
The mode field is the primary reason to branch on meta — Next.js requires a 'layout' scope argument when you want to invalidate the full layout tree:
revalidatePath: (path, meta) => {
if (meta.mode === 'site') {
return nextRevalidatePath(path, 'layout')
}
return nextRevalidatePath(path)
},
revalidateTag(tag, meta?)The Next.js 16 example uses { expire: 0 } for immediate expiration after CMS changes. Use 'max' if you prefer serving stale content while refreshing it in the background. See the Next.js tag revalidation documentation.
meta?: {
reason: RevalidationReason
scope: 'collection' | 'global'
slug: string
}
| Reason | When |
|---|---|
'collection-update' | Collection create or update operation |
'collection-unpublish' | Update that transitions a document from published to draft |
'collection-delete' | Collection delete operation |
'global-update' | Global doc change |
These are the defaults to be aware of — getting them wrong is a common source of missed revalidation:
shouldHandle — defaults to doc._status === 'published' or, if the document has no _status field at all, true. If you don't use Payload drafts, every publish/update will pass the default guard automatically. If you do use drafts, only published docs trigger revalidation by default. Override with a custom shouldHandle to change this. Note: collection unpublish handling runs before this guard.
operations — defaults to ['create', 'update', 'updateByID']. Override to select a subset of these content operations. Unpublish matching runs before this filter.
onDelete — not configured by default. Deletes are skipped without it. The plugin warns at startup for collection targets that define update resolvers but no onDelete.
revalidateAllPath — defaults to '/' when revalidateAllOnChange: true.
fullRebuild.shouldTrigger — defaults to context.probeStatus === 404. Override to trigger on other status codes or custom logic.
fullRebuild without probeURL — if fullRebuild is enabled but no target has a probeURL, no probe ever runs and the rebuild trigger is never reached. The plugin emits a warning at startup.
Invalid probeURL values — if a resolver returns an empty, relative, or non-HTTP URL, the plugin warns and skips probing for that operation.
Probe failures — network failures and timeouts produce probeStatus: null, so normal path/tag revalidation continues unless a custom shouldTrigger handles that status. Probe resolvers are not called when fullRebuild is absent or explicitly disabled.
Callback failures — plugin guard, resolver, revalidation, and rebuild-trigger errors propagate to Payload. Subsequent callbacks for the operation are not guaranteed to run. Handle recoverable errors inside your callbacks when continued processing is required.
When a collection update is detected as an unpublish, the plugin uses unpublish-specific resolvers if provided, falling back to the main resolvers.
Default unpublish matcher: the operation must be update or updateByID, and request data must include _status: 'draft'. Extra fields are allowed. This is an update-to-draft signal and does not strictly validate previous persisted state.
If your app uses a different field to control publish state (e.g. isPublished: boolean), provide a custom unpublish.matcher:
{
slug: 'posts',
pathResolver: ({ result }) => [`/posts/${result.slug}`, '/posts'],
unpublish: {
// Detect your custom unpublish pattern
matcher: ({ args, operation }) => {
if (operation !== 'update' && operation !== 'updateByID') return false
return args.data.isPublished === false
},
// Optional: different paths/tags on unpublish (falls back to main resolvers if omitted)
pathResolver: ({ result }) => [`/posts/${result.slug}`, '/posts'],
tagResolver: ({ result }) => ['posts', `post:${result.id}`],
},
}
Deletes do not trigger revalidation unless onDelete is configured on the target. The plugin warns at startup when onDelete is missing. The delete hook receives the deleted document and its ID:
{
slug: 'posts',
pathResolver: ({ result }) => [`/posts/${result.slug}`, '/posts'],
onDelete: {
pathResolver: ({ doc, id }) => [
// doc is the deleted document — use its fields if available
typeof doc.slug === 'string' ? `/posts/${doc.slug}` : `/posts/${id}`,
'/posts',
],
tagResolver: ({ id }) => ['posts', `post:${id}`],
},
}
When a document changes, other pages that embed or reference that document may also need their cache busted — for example, a pages entry that includes a post inside its block layout.
findReferencingPaths() handles this automatically. You give it the changed document's ID and the collections/globals to search, and it returns the paths of any documents that contain a reference to it. Use it inside referencePathResolver:
import { findReferencingPaths, payloadIsr } from '@ggaidelevicius/payload-isr'
{
slug: 'posts',
pathResolver: ({ result }) => [`/posts/${result.slug}`, '/posts'],
referencePathResolver: ({ req, result }) =>
findReferencingPaths({
payload: req.payload,
req,
referencedValues: result.id,
targets: {
collections: ['pages', 'news'],
globals: ['homepage'],
},
fieldPaths: ['layout'],
}),
}
This fetches candidate documents from pages, news, and homepage, then applies the default published filter before matching references and returning paths.
The helper walks the values at each fieldPath (or the roots returned by getSearchRoots) and checks whether any string or number matches one of the referencedValues. Dotted paths traverse arrays of blocks or relationships: layout.relatedPost checks relatedPost in every layout entry. Explicit indexes such as layout.0.relatedPost select only that entry. Matching supports deeply nested and cyclic search roots.
By default, only published documents are candidates (_status === 'published', or docs without _status). Override this with shouldInclude.
By default, queries run with depth: 0 and overrideAccess: true. This keeps relationship values as IDs (better for stable matching) and avoids access-scoped misses in system-level revalidation. Override with queryDepth / overrideAccess if your project needs different behavior.
Pass the hook's req to preserve its transaction, locale, user, and context. This is especially useful with overrideAccess: false. A candidate's failing shouldInclude, getSearchRoots, or resolvePaths callback is logged and skips only that document; other candidates continue to be checked.
For each matching document, the path is determined by the first of these that applies:
breadcrumbs array (if present and starts with /)/${doc.slug} (if the document has a non-empty slug field)/${doc.id}/ — only for globals that have none of the aboveOverride with resolvePaths when your routing doesn't follow this convention. Paths returned by resolvePaths must be absolute (start with /).
The helper doesn't know which fields store your block or relation data — you need to point it there.
fieldPaths accepts dot-separated paths to the fields that contain block or relation data:
fieldPaths: ['layout', 'hero.blocks', 'sidebar.content']
getSearchRoots is an escape hatch for when references don't live in predictable fields — it receives the full document and returns the values to search:
getSearchRoots: (doc, meta) => {
// Search the entire document for pages, only the hero section for others
if (meta.slug === 'pages') return [doc]
return [doc.hero]
}
When both fieldPaths and getSearchRoots are provided, their results are combined. At least one is required.
Override resolvePaths when the default path convention doesn't match your routing:
referencePathResolver: ({ req, result }) =>
findReferencingPaths({
payload: req.payload,
req,
referencedValues: result.id,
targets: {
collections: ['pages', 'news'],
},
fieldPaths: ['hero.blocks', 'layout'],
resolvePaths: (doc, meta) => {
if (meta.slug === 'news' && typeof doc.slug === 'string') {
return [`/news/${doc.slug}`]
}
return typeof doc.slug === 'string' ? [`/${doc.slug}`] : []
},
})
| Option | Required | Description |
|---|---|---|
payload | Yes | Payload instance. Available as args.req.payload in hook resolvers. |
req | No | Originating Payload request, preserving its transaction, locale, user, and context. Pass the hook's req. |
referencedValues | Yes | The ID(s) to search for — typically result.id. Accepts a single value or an array; null/undefined entries are ignored. |
targets | Yes | { collections?, globals? } — which slugs to scan for references. |
fieldPaths | One of fieldPaths/getSearchRoots | Dot-separated field paths to inspect on each candidate document (e.g. ['layout', 'hero.blocks']). Fields that don't exist on a document are silently skipped. |
getSearchRoots | One of fieldPaths/getSearchRoots | Function returning the values to search for a given document. Combined with fieldPaths results when both are provided. |
resolvePaths | No | Custom route mapper for matching documents. Must return absolute paths (starting with /). Defaults to: breadcrumb URL → /${slug} → /${id} → / (globals only). |
shouldInclude | No | Custom filter applied to each candidate document before the reference search runs. Defaults to published docs or docs without _status. |
queryDepth | No | Depth passed to Payload queries. Defaults to 0. Increase if you intentionally want populated relationship objects in the search roots. |
overrideAccess | No | Whether to bypass access control when scanning candidates. Defaults to true to avoid missed revalidation due to user-scoped access. |
logger | No | Logger for warnings from the helper (failed queries, non-absolute paths). Defaults to console. Pass the same logger you configured on the plugin to keep output consistent. |
MongoDB — MongoDB stores relationship IDs embedded within each document's structure. There is no join table or foreign-key index to reverse-query, so finding "all pages that reference post X" requires a full collection scan regardless. findReferencingPaths is the practical solution here.
PostgreSQL / SQLite — Payload's SQL adapters store relationships in dedicated join tables (e.g. pages_rels). In principle you could query those tables directly to find referencing documents without fetching full documents. findReferencingPaths doesn't do this — it uses payload.find() and scans the returned documents in memory, which is database-agnostic but less targeted than a raw SQL query. For large collections on a SQL adapter, a direct Drizzle query against the _rels table would be more efficient, though it requires knowing Payload's internal table naming conventions (which vary by collection and field structure).
findReferencingPaths fetches every document in each target collection on every publish event. Keep targets narrow — only include collections that actually store references to the changed document type.
fullRebuild is a fallback for situations where path/tag invalidation misses newly valid routes — for example, when a slug changes and the new URL has never been cached, or when catch-all routes return 404 until a new build is deployed.
When to enable it:
404 until a rebuildHow it works:
fullRebuild must be configured, with enabled not set to falseprobeURL resolver — without it, no probe runsprobeURL after a publish/updatefullRebuild.shouldTrigger(context) returns true (default: probeStatus === 404), trigger() is calledfullRebuild: {
enabled: process.env.NODE_ENV === 'production',
trigger: async (context) => {
// context: { probeStatus, probeURL, reason, scope, slug }
await fetch(process.env.REBUILD_WEBHOOK_URL!, { method: 'POST' })
},
}
Common trigger implementations:
All ISR inputs for a content type should map to the same routing contract your app actually serves. Misalignment means revalidating paths that aren't cached, or probing URLs that don't match what's live.
Rules of thumb:
pathResolver should return the paths your app actually caches and servesprobeURL should be the user-facing URL you expect to exist after a successful deploy/posts/[id] and /posts/[slug], revalidate bothreferencePathResolver can revalidate the previous URL if your resolver can derive it (e.g. from stored history)Example — helper functions that stay consistent across resolvers:
const getPostPaths = (doc: { id: string | number; slug?: null | string }) => {
const idPath = `/posts/${String(doc.id)}`
const slugPath = typeof doc.slug === 'string' && doc.slug.trim() ? `/posts/${doc.slug.trim()}` : null
return [slugPath, idPath, '/posts'].filter(Boolean) as string[]
}
const getPostProbeURL = (doc: { id: string | number; slug?: null | string }) =>
new URL(
typeof doc.slug === 'string' && doc.slug.trim()
? `/posts/${doc.slug.trim()}`
: `/posts/${String(doc.id)}`,
process.env.PUBLIC_APP_URL,
).toString()
// Use in config:
{
slug: 'posts',
pathResolver: ({ result }) => getPostPaths(result),
probeURL: ({ result }) => getPostProbeURL(result),
onDelete: {
pathResolver: ({ doc, id }) => getPostPaths({ id, slug: doc.slug }),
},
}
Enable debug traces:
payloadIsr({
debug: true,
logger: createPayloadIsrLogger(),
// ...
})
createPayloadIsrLogger() prefixes output with [payload-isr] and filters out noisy config.* setup traces by default. To include config-level events:
logger: createPayloadIsrLogger({ includeConfigDebugEvents: true })
Bring your own logger by passing any object with error, warn, and optionally info methods:
logger: {
error: (...args) => myLogger.error(...args),
warn: (...args) => myLogger.warn(...args),
info: (...args) => myLogger.info(...args),
}
Startup preflight warnings — the plugin validates configuration at init and warns about:
onDelete)onDelete configured but no resolvers inside itrevalidatePath callbacktagResolver without a revalidateTag callbackfullRebuild enabled with no probeURL resolversrevalidateAllOnChange and pathResolver on the same global targetrevalidateAllPathpnpm hooks:install # install commit-msg and other git hooks
pnpm dev # start the bundled dev app
pnpm test:int # run all unit and integration tests once
pnpm lint # check source, tests, and development configuration
pnpm build # build the plugin
pnpm publish:check # lint, test, rebuild, and inspect the package contents
Builds use the TypeScript 7 native compiler. The typescript dependency aliases Microsoft's TypeScript 6 compatibility package for tools that need the JavaScript compiler API. The parser overrides keep Payload's lint configuration compatible with ESLint 10. Integration tests create a temporary MongoDB replica set and close it, along with Payload, when the suite finishes.
Pull requests and pushes to main run pnpm publish:check in CI. Publishing remains restricted to commits with a valid release marker.
Environment variables for the bundled dev/ app:
| Variable | Default | Description |
|---|---|---|
PAYLOAD_ISR_DEBUG | 1 | Emit branch-level debug traces |
PAYLOAD_ISR_DEBUG_CONFIG | off | Include noisy config.* trace events |
PAYLOAD_ISR_FULL_REBUILD | off | Enable full-rebuild fallback simulation |
PAYLOAD_ISR_PROBE_ORIGIN | http://127.0.0.1:3000 | Base URL for probe requests |
Dev API endpoints:
GET /api/isr-debug — inspect recorded revalidation telemetryDELETE /api/isr-debug — clear recorded telemetryRelease commit marker guard: commit messages containing (release...) must use exactly one of (release:patch), (release:minor), or (release:major). Invalid values (e.g. (release:path)) are rejected by the commit-msg hook.
payload better editor
Side-by-side live-preview iframe with a sidebar for editing individual blocks in the Payload edit view
781.2k/wk119v3
payload plugin scheduling
Schedule future publication of drafts on collections and globals with a secured cron endpoint
77783/wk37v3
payload plugin comments
Document-level and field-level comments with mentions, resolution and email notifications for Payload admin
757.0k/wk37v3
payload revalidate
Transaction-aware cache revalidation hooks for Payload with a signed Next.js route handler
75218/wk3v3
payload plugin html preview
Live preview and click-to-edit in the Payload admin for any frontend that renders HTML, no framework needed
74451/wk37v3
payload plugin roadmap
Public roadmap with voting, curator-set stages, deduplicated requests and an optional features catalog
74194/wk0v3