Documentation

Notifications

Notifications

Send persistent notifications from a VitNode plugin, with an inbox under the bell, a live unread count, email and daily or weekly digests.

VitNode notifications give every member an inbox under the bell in the site header. A plugin calls c.get("notifications").publish() from an API route. Core then stores the notification, delivers it to each recipient, updates their unread count live and sends email to members who asked for it.

The notification bell open in the site header, showing three unread notifications and a Mark all as read button

What your plugin does and what core does

Your plugin decides who might care about something. Core decides who actually receives it, and how.

Your pluginCore
Declares a notification type with buildNotificationTypeLists the type on every member's preferences page
Passes candidate user ids as recipientsDrops the actor, deleted users and members who turned the type off
Answers "who may see this?" in accessCalls access in batches, again before email and when the inbox loads
Returns plain text from presentStrips markup, drops unsafe links and translates per recipient
Sends one idempotencyKey per real-world eventIgnores repeats, retries failed work and never delivers twice

Notification or toast?

A notification is stored until the member reads or archives it. A toast is a short message sent over the WebSocket to open tabs, and it is gone after a reload.

You want toUse
Tell a member something they may look for later, such as a reply or an approvalc.get("notifications").publish()
Give feedback about something happening right now, such as "Import started"A toast with c.get("realtime").sendToUser(), see WebSocket

Pick a guide

You want toGuide
Send your first notification from a pluginPublish notifications
Hide notifications from members who cannot see the contentLimit who sees a notification
Send a notification by email or in a daily or weekly digestEmail and digests
Replace a plugin's toasts with stored notificationsMove from toasts to notifications
Change what members get by default, or pause everythingNotifications in the AdminCP
Fix a bell that does not update, or email that never arrivesTroubleshooting
Look up every option of buildNotificationTypeNotification types
Look up publish(), remove() and the REST endpointsNotifications API reference

To understand what happens after publish(), read Inbox and realtime, Preferences and Queue and scale.