krzysztofradomski

payload plugin admin alerts

by krzysztofradomski
Admin customization
v3
^3.0.0

Overview

Summary generated from the README

Adds an admin-alerts collection and a dashboard panel to the Payload admin so users can author messages and show them on the home page. Alerts can go to all authenticated users or selected users, and each user can dismiss them individually. It registers as a plugin and works with Payload 3 and a configurable users collection.

Features

  • admin-alerts collection with title, content, type, status, audience and dismissable flag
  • Alert types info, success, warning and error with matching styling
  • Audience targeting for all users or selected users
  • Per-user dismissals stored in a dismissedBy field via a dismiss endpoint
  • Dashboard panel and live alert preview in the edit view
  • Alerts can be created from hooks or jobs through the Local API

Use cases

  • Announce maintenance windows or releases to all admin users on the dashboard
  • Notify a specific author when their draft is rejected
  • Alert editors when content is published through an afterChange hook

From the author

Dashboard system alerts for the Payload CMS admin UI — author messages, target audiences, allow per-user dismissals.

Installation

npm i payload-plugin-admin-alerts

1

Stars

0

Forks

0

Open Issues

6 months ago

Last Updated

5

Weekly Downloads

v1.0.0

npm Version

130.7 KB

Unpacked Size

0

Dependencies

GitHub stars

10 since Sep 7

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

6−15 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 20266
Dec 5, 20268
Dec 4, 20269
Dec 3, 20268
Dec 2, 20267
Dec 1, 202610
Nov 30, 202610
Nov 29, 20269
Nov 28, 20265
Nov 27, 20264
Nov 26, 20266
Nov 25, 20266
Nov 24, 20263
Nov 23, 20263
Nov 22, 20265
Nov 21, 20265
Nov 20, 20266
Nov 19, 20268
Nov 18, 202611
Nov 17, 202613
Nov 16, 202616
Nov 15, 202619
Nov 14, 202620
Nov 13, 202623
Nov 12, 202622
Nov 11, 202621
Nov 10, 202620
Nov 9, 202619
Nov 8, 202620
Nov 7, 202630
Nov 6, 202627
Nov 5, 202627
Nov 4, 202628
Nov 3, 202629
Nov 2, 202634
Nov 1, 202632
Oct 31, 202624
Oct 30, 202627
Oct 29, 202624
Oct 28, 202621
Oct 27, 202629
Oct 26, 202626
Oct 25, 202625
Oct 24, 202628
Oct 23, 202623
Oct 22, 202630
Oct 21, 202633
Oct 20, 202628
Oct 19, 202628
Oct 18, 202630
Oct 17, 202629
Oct 16, 202632
Oct 15, 202628
Oct 14, 202628
Oct 13, 202623
Oct 12, 202622
Oct 11, 202620
Oct 10, 202618
Oct 9, 202619
Oct 8, 202624
Oct 7, 202625
Oct 6, 202626
Oct 5, 202627
Oct 4, 202628
Oct 3, 202628
Oct 2, 202635
Oct 1, 202642
Sep 30, 202642
Sep 29, 202644
Sep 28, 202643
Sep 27, 202649
Sep 26, 202652
Sep 25, 202644
Sep 24, 202631
Sep 23, 202630
Sep 22, 202631
Sep 21, 202631
Sep 20, 202627
Sep 19, 202626
Sep 18, 202625
Sep 17, 202627
Sep 16, 202627
Sep 15, 202625
Sep 14, 202626
Sep 13, 202624
Sep 12, 202621
Sep 11, 202623
Sep 10, 202621
Sep 9, 202621
Sep 8, 202620
Sep 7, 202621

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

Health Score

35/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/1243726777-root.svg)](https://payloaddirectory.dev/plugins/1243726777-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1243726777-root"><img src="https://payloaddirectory.dev/badge/1243726777-root.svg" alt="Payload Directory"></a>
Updated May 19, 2026Created May 19, 2026Published May 19, 2026

README

payload-plugin-admin-alerts

Dashboard system alerts for the Payload CMS admin UI. Author messages from the admin panel, target an audience (everyone or specific users), and let users dismiss them individually.

Features

  • admin-alerts collection for authoring messages (title, content, type, audience, dismissable flag)
  • Per-user dismissals tracked inline on the alert via a dismissedBy relationship field — no extra collection
  • Alert types: info, success, warning, error
  • Audience targeting: broadcast to all authenticated users, or pick specific users
  • "Active" / "Inactive" status for taking alerts down without deleting them
  • Dashboard panel that fetches and renders alerts on the admin home page
  • Per-user dismissal endpoint (POST /admin-alerts/:id/dismiss)
  • Access control: only the alert author can edit or delete; any authenticated user can read

Installation

pnpm add payload-plugin-admin-alerts
# or: npm install payload-plugin-admin-alerts
# or: yarn add payload-plugin-admin-alerts

Peer requirements: payload ^3.0.0, @payloadcms/ui ^3.0.0, react ^18 || ^19, react-dom ^18 || ^19.

Usage

Add the plugin to your payload.config.ts:

import { buildConfig } from 'payload'
import { payloadAdminAlerts } from 'payload-plugin-admin-alerts'

export default buildConfig({
  plugins: [
    payloadAdminAlerts({
      // defaults shown
      disabled: false,
      usersCollectionSlug: 'users',
    }),
  ],
  // ...
})

That's it. After Payload restarts you'll see a System → Admin Alerts entry in the admin nav and a new alerts panel on the dashboard.

Configuration

type PayloadAdminAlertsConfig = {
  /**
   * Disable the runtime behavior (dashboard UI + endpoints) while keeping
   * the collections registered, so the database schema stays consistent.
   * @default false
   */
  disabled?: boolean

  /**
   * Auth collection slug used for alert authors and audience targeting.
   * @default 'users'
   */
  usersCollectionSlug?: string
}
OptionTypeDefaultNotes
disabledbooleanfalseSkips registering the dashboard component and endpoints. Collections stay so migrations don't break.
usersCollectionSlugstring'users'Used by the createdBy and targetUsers relationship fields, and by access control checks.

Creating alerts from hooks

Alerts are a normal Payload collection (admin-alerts). Create them from any collection hook, job, or endpoint with the Local API — for example, notify editors when content goes live:

import type { CollectionAfterChangeHook, CollectionConfig } from 'payload'

const alertOnPublish: CollectionAfterChangeHook = async ({
  doc,
  operation,
  previousDoc,
  req,
  context,
}) => {
  // Only run once per publish, not on every save
  if (context.skipAdminAlert) return
  if (operation !== 'update') return
  if (doc._status !== 'published' || previousDoc?._status === 'published') return

  await req.payload.create({
    collection: 'admin-alerts',
    data: {
      title: `Published: ${doc.title}`,
      content: 'A new post is live. Review it from the dashboard if needed.',
      type: 'success',
      status: 'active',
      audience: 'all',
      dismissable: true,
    },
    req, // pass req so the alert stays in the same transaction
    user: req.user, // createdBy is auto-set from the authenticated user
  })
}

export const Posts: CollectionConfig = {
  slug: 'posts',
  versions: { drafts: true },
  hooks: {
    afterChange: [alertOnPublish],
  },
  fields: [
    { name: 'title', type: 'text', required: true },
    // ...
  ],
}

Target a specific user (for example, the post author) instead of broadcasting:

await req.payload.create({
  collection: 'admin-alerts',
  data: {
    title: 'Your draft was rejected',
    content: 'An editor left feedback on your submission.',
    type: 'warning',
    status: 'active',
    audience: 'selected',
    targetUsers: [authorId],
    dismissable: true,
  },
  req,
  user: req.user,
})

Notes

  • Pass req into nested create calls so the alert participates in the same database transaction as the triggering operation.
  • Pass user: req.user when the hook runs in an authenticated request; the plugin sets createdBy automatically on create.
  • For system/cron contexts with no req.user, use overrideAccess: true and set createdBy yourself if you need an author for update/delete access.
  • Use req.context flags (for example context.skipAdminAlert) if your hook chain could re-trigger itself.

Collections

admin-alerts

Authored from the admin panel. Fields:

FieldTypePurpose
titletext, requiredHeading shown on the dashboard card
contenttextarea, requiredBody text
typeselectinfo / success / warning / error — drives the styling
statusselectactive / inactive — only active alerts are surfaced
dismissablecheckboxIf true, users can dismiss the alert for themselves
audienceselectall or selected
targetUsersrelationship[]Shown only when audience === 'selected'
createdByrelationshipAuto-populated on create, read-only
dismissedByrelationship[]Users who have dismissed this alert; edit to re-show or pre-dismiss for specific users
alertPreviewui fieldLive preview of how the alert will render on the dashboard

Dismissals

Dismissals live on the alert itself as the dismissedBy relationship array — no separate collection. POST /admin-alerts/:id/dismiss appends the requesting user to the field; the dashboard query filters out alerts where the current user appears in dismissedBy. To re-show an alert to a specific user, remove them from dismissedBy. To re-broadcast to everyone who'd dismissed it, clear the field.

Endpoints

The plugin registers two endpoints (mounted under your Payload API route, typically /api):

MethodPathDescription
GET/admin-alerts/dashboardReturns { alerts: DashboardAlert[] } for the current user
POST/admin-alerts/:id/dismissRecords a dismissal for the current user

Both require an authenticated request.

Access control

  • Read any alert: any authenticated user
  • Create an alert: any authenticated user (you become createdBy)
  • Update / Delete: only the user who authored the alert

Dismissals are write-only and scoped to the requesting user.

Local development

pnpm install
pnpm dev          # starts the dev/ Payload app on http://localhost:3000
pnpm test:unit    # vitest unit tests
pnpm test:e2e     # playwright e2e tests
pnpm check        # typecheck + lint + tests

The dev/ directory contains a minimal Payload app preconfigured with the plugin.

Publishing

pnpm publish

prepublishOnly cleans dist/ and rebuilds. publishConfig swaps the source-pointing exports for the compiled dist/ outputs at publish time, so consumers always get the built files.

License

MIT

Media

This plugin was tested and developed in relation to my upcoming fairytale builder app.

Info example Darkmode example

Similar plugins