elghaied

payload plugin notifications

by elghaied
Notifications & messaging
v3
^3.84.1
MIT

Overview

Summary generated from the README

Adds a notifications collection and a bell in the admin header showing an unread count and a dropdown feed. New notifications are stored as database rows and pushed live to open admin tabs via server-sent events. Notifications are created with a pushNotification helper from any hook, endpoint or job. Requires Payload 3 and works best on a long-running Node process; optional multi-tenant scoping is available.

Features

  • Admin header bell with unread count and dropdown feed with relative timestamps
  • Custom paginated notifications list view replacing the default table
  • Live updates over server-sent events with graceful fallback when SSE cannot connect
  • pushNotification helper to create notifications from hooks, endpoints or jobs
  • Each user can read, mark read and dismiss only their own notifications
  • Ships translations for 12 languages with RTL support and optional tenant scoping

Use cases

  • Alert editors in the admin when an invoice is paid or a document is updated
  • Notify users of system events from collection hooks without leaving the dashboard
  • Show per-tenant notifications in a multi-tenant admin panel

From the author

In-dashboard notifications for the Payload admin, with a live SSE bell.

Installation

npm i @elghaied/payload-plugin-notifications

7

Stars

0

Forks

0

Open Issues

6 months ago

Last Updated

9

Weekly Downloads

v1.0.0

npm Version

118.9 KB

Unpacked Size

0

Dependencies

GitHub stars

7+2 since Sep 7

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

7−9 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 20267
Dec 5, 20268
Dec 4, 202614
Dec 3, 202616
Dec 2, 202616
Dec 1, 202617
Nov 30, 202617
Nov 29, 202619
Nov 28, 202616
Nov 27, 202615
Nov 26, 202618
Nov 25, 202621
Nov 24, 202621
Nov 23, 202622
Nov 22, 202624
Nov 21, 202630
Nov 20, 202626
Nov 19, 202620
Nov 18, 202620
Nov 17, 202617
Nov 16, 202617
Nov 15, 202613
Nov 14, 202612
Nov 13, 202611
Nov 12, 202612
Nov 11, 202611
Nov 10, 202612
Nov 9, 202613
Nov 8, 202613
Nov 7, 20269
Nov 6, 20269
Nov 5, 202610
Nov 4, 20268
Nov 3, 202611
Nov 2, 202610
Nov 1, 202611
Oct 31, 202610
Oct 30, 20269
Oct 29, 20267
Oct 28, 20267
Oct 27, 20266
Oct 26, 20267
Oct 25, 20267
Oct 24, 202611
Oct 23, 202611
Oct 22, 202613
Oct 21, 202614
Oct 20, 202613
Oct 19, 202612
Oct 18, 202614
Oct 17, 20269
Oct 16, 202610
Oct 15, 20269
Oct 14, 20269
Oct 13, 20268
Oct 12, 20267
Oct 11, 20266
Oct 10, 20267
Oct 9, 202610
Oct 8, 202610
Oct 7, 202610
Oct 6, 202610
Oct 5, 202611
Oct 4, 202611
Oct 3, 202615
Oct 2, 202615
Oct 1, 202614
Sep 30, 202615
Sep 29, 202619
Sep 28, 202625
Sep 27, 202626
Sep 26, 202632
Sep 25, 202629
Sep 24, 202630
Sep 23, 202628
Sep 22, 202625
Sep 21, 202619
Sep 20, 202617
Sep 19, 20268
Sep 18, 20267
Sep 17, 20268
Sep 16, 202612
Sep 15, 202612
Sep 14, 202611
Sep 13, 202610
Sep 12, 202613
Sep 11, 202614
Sep 10, 202612
Sep 9, 202610
Sep 8, 202611
Sep 7, 202616

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

Health Score

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

README

@elghaied/payload-plugin-notifications

npm version npm downloads license

In-dashboard notifications for the Payload admin, with a live bell that updates without a page refresh.

  • 🔔 A NotificationBell in the admin header — unread count + dropdown feed with compact relative timestamps ("now", "40m", "2d"); unread rows highlighted, read rows dimmed; click a row to mark it read and go where it points.
  • 📋 A custom notifications list view — Payload's default table is replaced with a clean, paginated feed (same row, whole-row click marks read + navigates). Reached via "See all".
  • ⚡ Live via Server-Sent Events (best-effort), with graceful degradation when SSE can't connect.
  • 🗄️ Every notification is a real DB row (the source of truth) — adapter-agnostic (Mongo or Postgres), opaque ids.
  • 🔒 Notification links are scheme-validated before navigation (no javascript:/data: XSS).
  • 🌍 Translated UI strings, field labels, and collection labels — ships 12 languages (ar, de, en, es, fr, hi, id, it, pl, ru, tr, zh), RTL-aware; user translations override.
  • 🧩 Additive and default-off; optional multi-tenant scoping.

Screenshots

Bell dropdownCustom list view
Notification bell dropdown open over the admin, showing recent notifications with relative timestampsCustom notifications list view replacing Payload's default table

Unread rows carry an accent bar and bolded text; read rows are dimmed. Times are compact and relative (now, 8m, 3h, 2d, 1w), with the full timestamp on hover.

How it works

Two decoupled layers:

  1. Source of truth — a notifications collection row. Created via pushNotification(). A user sees their notifications whether or not a tab was open when they were created.
  2. Live channel — an afterChange hook on the collection emits each new row over SSE to that recipient's open admin tabs (in-memory connection registry). This is the only live-push path, and it's a side effect of the DB write — never a separate path.

Designed for a long-running Node process (self-hosted), where SSE connections hold. On serverless or behind a buffering proxy the bell still shows accurate counts on mount and on dropdown-open — it just won't pop instantly.

Install

pnpm add @elghaied/payload-plugin-notifications

Usage

// payload.config.ts
import { payloadPluginNotifications } from '@elghaied/payload-plugin-notifications'

export default buildConfig({
  plugins: [
    payloadPluginNotifications(),
  ],
})

That adds the notifications collection (hidden from the nav) and the live bell in the admin header.

Sending a notification

pushNotification is a thin wrapper over payload.create (with overrideAccess), callable from any hook, endpoint, or job:

import { pushNotification } from '@elghaied/payload-plugin-notifications'

await pushNotification(payload, {
  recipient: user.id,
  message: 'Invoice #1042 was paid',
  link: '/admin/collections/invoices/1042',
  type: 'success', // 'info' | 'warning' | 'success'
})

// Inside a hook, pass `req` so the create joins the same transaction:
await pushNotification(req.payload, { recipient, message: 'Updated', req })

REST create is denied — notifications are system-generated. Each user can only read, mark-read, and dismiss their own notifications.

Configuration

payloadPluginNotifications({
  disabled,          // boolean   — default false. Installed but inert; DB schema stays stable.
  notificationsSlug, // string    — default 'notifications'
  usersSlug,         // string    — default 'users'. The auth collection notifications target.
  tenants: {         // object    — OMIT for single-tenant (recipient-only scoping).
    tenantsSlug,     //   string  — default 'tenants'
    tenantFieldName, //   string  — default 'tenant'
  },
  hideFromNav,       // boolean   — default true. The bell is the UI surface.
})

Multi-tenancy

When the tenants block is set, the plugin adds a required tenant relationship field and ANDs a tenant filter into read access. It interoperates with @payloadcms/plugin-multi-tenant but doesn't depend on it.

The default filter assumes one tenant per user (user[tenantFieldName]). The official multi-tenant plugin models users with a tenants array — for that model you'll want a custom tenant filter (a tenantFilter config hook is the planned extension point).

Notifications collection

fieldtypenotes
recipientrelationship → usersrequired
tenantrelationship → tenantsonly when multi-tenant is enabled (required)
messagetextrequired
linktexte.g. /admin/collections/invoices/123
typeselectinfo | warning | success
readcheckboxdefault false

Extension points (not built in v1)

  • Background jobs / digests — pushNotification() is the single seam where payload.jobs.queue() would swap in for async or scheduled/digest notifications.
  • Multi-replica live push — the NotificationRegistry interface (in-memory today) accepts a distributed implementation (Postgres LISTEN/NOTIFY or Mongo change streams). No Redis.

License

MIT

Similar plugins