A lightweight utility for deferring Payload CMS collection hooks into background jobs or workflows. Version 0.0.1 is the initial release, designed for Payload 2.x+. It captures hook payloads (beforeChange, afterChange, etc.) and pushes them to a queue for async processing, reducing request latency and preventing hook failures from blocking API responses. Unlike custom job runners, it integrates directly with Payload's hook system and can work with any queue backend (Bull, Redis, etc.) via a simple adapter pattern. Ships TypeScript types.
npm install payload-hooks-queueNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a Bull queue adapter and attaches it to a Payload collection's afterChange hook for async processing.
Install the queue adapter: npm install bull (or redis, etc.)
Pin to a specific version and test upgrades thoroughly.
Wrap enqueue in try/catch or use a fallback synchronous handler.
npm install payload-hooks-queue
Use import { createHookQueue } from 'payload-hooks-queue' and ensure "type": "module" in package.json or use .mjs extension.Ensure the hook array item is the result of myQueue.enqueue({...}) which returns a function wrapping the queued handler.