Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Node.js library for handling notifications (in web apps).
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test Fixed bug, updated readme
index.js fixed bug
package.json initial commit


npm install notif


notif.send(actor, verb [, object]);


notif.send({ username: 'olalonde' }, 'followed', { username: 'bobby' });

Every notification is internally represented by an object containing the following properties:


  • time : {Object} Date() object that is automatically assigned when notification is created.
  • actor : {Object} A generic object that identifies the user or entity that performed the activity.
  • verb : {String} A verb that identifies the action of the activity.
  • object : (optional) {Object} The primary object of the activity.

Note: This library follows the Atom Activity Streams nomenclature.

Registering verb handlers

notif.register('followed', function (notification, cb) {
  // we assume that the notification object looks like this 
  // after bob followed oli:
  // {
  //   actor: bob
  //   verb: 'followed'
  //   object: oli
  // }

  // let's notify oli that he just got followed
  // and an activity to bob's activity stream 
  // but not in his notification center

  var activity = new Activity();

  // specify on whose stream we want the notification to show up
  activity._user = notification.object._id;
  activity._actor =;
  activity._object = notification.object._id;
  activity.createdAt = notification.time; 
  // for example: private, public, notification center
  //activity.markRead(); (err) {
    if (err) console.error(err);

notif.register('logged in', function (notification) {


notif.register({ except: ['delete account'] }, function (notification) {
  console.log('good news!');

notif.register({ only: ['registered'] }, function (notification) {
  // send email...

notify.register(function (notification) {
  //console.log( + ' ' + notification.verb + ' ' + notifications.object);


Something went wrong with that request. Please try again.