hooks
Installation
SKILL.md
PayloadCMS — Hooks
Hooks let you inject logic at every step of a document's lifecycle. They live on collections, globals, and individual fields. Use them for slug generation, audit logs, cache invalidation, side effects (email, webhooks), and computed values — without forking the admin or the API.
Hook Categories
| Where | Available hooks |
|---|---|
| Collection | beforeOperation, beforeValidate, beforeChange, afterChange, beforeRead, afterRead, beforeDelete, afterDelete, afterOperation, afterError, plus auth-only: beforeLogin, afterLogin, afterLogout, afterForgotPassword, afterMe, afterRefresh |
| Global | beforeValidate, beforeChange, afterChange, beforeRead, afterRead |
| Field | beforeValidate, beforeChange, afterChange, afterRead |
Every hook is an array — Payload runs them in order. Plugins append to these arrays; never overwrite.
Hook Argument Shape
Every collection hook receives roughly the same args (precise shape varies per hook). Common keys: