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 🙏

© 2025 – Pkg Stats / Ryan Hefner

notifypro

v0.1.4

Published

A flexible notification system for React applications

Readme

React Notifypro

A flexible, customizable notification system for React applications.

Features

  • 🚀 Multiple notification types: success, error, warning, info
  • ⏱️ Auto-dismissing notifications with progress bar
  • 🔧 Customizable positions: top-right, top-left, top-center, bottom-right, bottom-left, bottom-center
  • 🎨 Theme support for light and dark modes
  • ⚙️ Configurable duration, max count, and persistence
  • 🔄 Promise support for handling asynchronous operations
  • ♿ Accessibility features: keyboard navigation, screen reader support

Installation

npm install notifypro

or

yarn add notifypro

Quick Start

Wrap your application with the NotificationProvider:

import React from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
import { NotificationProvider } from 'notifypro';

const root = createRoot(document.getElementById('root'));

root.render(
  <React.StrictMode>
    <NotificationProvider>
      <App />
    </NotificationProvider>
  </React.StrictMode>
);

Then use the useNotification hook in your components:

import React from 'react';
import { useNotification } from 'notifypro';

function MyComponent() {
  const { success, error, warning, info } = useNotification();
  
  const handleClick = () => {
    success('Operation completed successfully!');
  };
  
  return (
    <button onClick={handleClick}>
      Show Notification
    </button>
  );
}

API

NotificationProvider

Wrapper component that provides the notification context.

<NotificationProvider
  config={{
    position: 'top-right', // Position of notifications
    duration: 5000, // Default duration in ms
    maxCount: 5, // Maximum number of notifications to show
    theme: 'light', // Theme: 'light' or 'dark'
  }}
>
  {children}
</NotificationProvider>

useNotification Hook

const {
  // Show notifications by type
  success,
  error,
  warning,
  info,
  
  // Advanced functions
  addNotification,
  removeNotification,
  clearNotifications,
  promise,
  
  // State
  notifications,
  config,
} = useNotification();

Basic Notification Functions

All notification functions accept content and options:

// Basic usage
success('Operation completed!');

// With options
error('Something went wrong!', {
  duration: 10000, // Duration in ms
  persist: true, // Prevent auto-dismissal
});

// Using JSX content
warning(() => (
  <div>
    <h4>Warning!</h4>
    <p>This is a complex notification.</p>
  </div>
));

Promise Support

Handle asynchronous operations with notifications:

const { promise } = useNotification();

const fetchData = async () => {
  try {
    const result = await promise(
      fetch('/api/data').then(res => res.json()),
      {
        loading: 'Fetching data...',
        success: 'Data loaded successfully!',
        error: 'Failed to load data',
        // Optional durations
        successDuration: 3000,
        errorDuration: 8000,
      }
    );
    
    // Handle the result
    console.log(result);
  } catch (error) {
    // Error is already handled by the notification
    console.error(error);
  }
};

Customize Content

Render Customize react component in notification,

info(() => (
  <div>
    <h4>Custom Component</h4>
    <p>This is a custom React component in a notification!</p>
    <button onClick={() => console.log('Clicked inside notification')}>
      Click me
    </button>
  </div>
));

useNotificationState Hook

Access notification state without the action functions:

import { useNotificationState } from 'notifypro';

function NotificationCounter() {
  const { notifications } = useNotificationState();
  
  return (
    <div>
      Active notifications: {notifications.length}
    </div>
  );
}

Customization

Positions

Import the POSITIONS constant to use predefined positions:

import { POSITIONS } from 'notifypro';

<NotificationProvider
  config={{
    position: POSITIONS.TOP_CENTER,
  }}
>
  {children}
</NotificationProvider>

Available positions:

  • TOP_LEFT
  • TOP_RIGHT
  • TOP_CENTER
  • BOTTOM_LEFT
  • BOTTOM_RIGHT
  • BOTTOM_CENTER

Notification Types

Import the NOTIFICATION_TYPES constant for type references:

import { NOTIFICATION_TYPES } from 'notifypro';

// Using the addNotification function
const { addNotification } = useNotification();

addNotification({
  type: NOTIFICATION_TYPES.SUCCESS,
  content: 'Custom notification',
  duration: 3000,
});

Available types:

  • SUCCESS
  • ERROR
  • WARNING
  • INFO

License

MIT