npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rm-pushnotify

v1.0.0

Published

A library for handling push notifications with service workers.

Downloads

3

Readme

🚀 PushNotification Library

npm version License: MIT

The PushNotification Library is a lightweight, easy-to-use JavaScript library that simplifies the process of managing browser notifications and service workers. Whether you're a beginner or an experienced developer, this library makes it straightforward to integrate notifications into your web application.


✨ Features

  • 🎛️ Singleton Design Pattern: Ensures only one instance of the library is created.
  • ⚙️ Service Worker Management: Register, unregister, and update service workers effortlessly.
  • 🔔 Easy Notification Display: Customize notifications with titles, icons, and more.
  • 🌐 Cross-Browser Compatibility: Works with modern browsers supporting Service Workers and Notifications API.
  • 🪶 Lightweight: Minimal setup and fast performance.

📦 Installation

Install the library via npm or yarn:

  npm install rm-pushnotify
  # or
  yarn add rm-pushnotify

Live DEMO

See the implementation here


📖 Usage Guide

➡️ Import the Library

import PushNotification from 'rm-pushnotify';

➡️ Initialize the PushNotification Instance

const pushNotification = new PushNotification('/sw.js');

➡️ Request Notification Permission

await pushNotification.requestPermission();

➡️ Register the Service Worker

const registration = await pushNotification.registerServiceWorker();

➡️ Show Notifications

pushNotification.showNotification('Hello, World!', {
    body: 'This is a test notification!',
    icon: '/path-to-icon/icon.png',
});

➡️ Create a new file sw.js at root of project. Put below content

// src/sw.js
self.addEventListener('push', function (event) {
    const data = event.data.json();
    const options = {
        body: data.body,
        icon: 'icon.png',
    };

    event.waitUntil(
        self.registration.showNotification(data.title, options)
    );
});

self.addEventListener('notificationclick', function (event) {
    const action = event.action;

    if (action === 'open_app') {
        event.waitUntil(
            clients.openWindow('/') // Open your app or a specific URL
        );
    } else if (action === 'dismiss') {
        event.notification.close(); // Close the notification
    } else {
        event.waitUntil(
            clients.openWindow('/') // Fallback to opening the app
        );
    }
});


💻 Compatibility

This library is written in JavaScript and is compatible with:

  • Frameworks: Angular, React, Vue.js, Vanilla JavaScript
  • Node.js Versions: 14.x and above
  • Package Managers: npm, yarn

🌐 Browser Support

| Browser | Notifications API | Service Workers | |----------------|-------------------|-----------------| | Chrome | ✅ Supported | ✅ Supported | | Firefox | ✅ Supported | ✅ Supported | | Microsoft Edge | ✅ Supported | ✅ Supported | | Safari (macOS) | ✅ Limited Support | ❌ Not Supported | | Safari (iOS) | ❌ Not Supported | ❌ Not Supported |

Note: Ensure your application uses HTTPS, as service workers require a secure context.


🔒 Security Best Practices

  • HTTPS Only: Always serve your application over HTTPS.
  • Update Regularly: Keep your service worker updated to avoid vulnerabilities.
  • No Sensitive Data: Avoid exposing sensitive data in your service worker.

🐛 Issues

If you encounter any issues:

  1. Search existing issues in the GitHub repository.
  2. Create a new issue with detailed steps to reproduce the problem.

👨‍💻 Author Services

Are you interested in this library but lacks features? Write to the author, he can do it for you.


🔑 Keywords

  • Push Notifications
  • JavaScript Library
  • Service Workers
  • Browser Notifications
  • Notifications API
  • Web Development

📜 License

This library is licensed under the MIT License.


👤 Author

Rajat Malik