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

@tanmaycodess/react-notify

v0.1.1

Published

notification/toast system for React

Readme

@tanmay/react-notify

A lightweight, dependency-free notification/toast system for React.

Designed for real-world workflows, not just UI alerts.


Features

  • Global notification provider
  • Simple hook-based API
  • Multiple notification types
    • success
    • error
    • warning
    • violation
    • info
  • Multiple positions
  • Auto-dismiss with progress bar
  • Persistent notifications (duration: null)
  • Unique Feature 1: ID-based workflow control
  • Unique Feature 2: 🔥 promise() helper for async flows (Axios, fetch, proctoring, uploads)

Installation

npm install @tanmay/react-notify

Setup

Wrap your app with NotificationProvider

import { NotificationProvider } from "@tanmay/react-notify";
import App from "./App";

export default function Root() {
  return (
    <NotificationProvider
      maxNotifications={5}
      defaultPosition="top-right"
      defaultDuration={5000}
    >
      <App />
    </NotificationProvider>
  );
}

Provider Props

| Prop | Type | Default | Description | | ------------------ | ------------- | ----------- | ----------------------------------------- | | maxNotifications | number | 5 | Max visible notifications | | defaultPosition | string | top-right | Default toast position | | defaultDuration | number | null | 5000 | Auto close duration (null = persistent) |


Using Notifications

import { useNotification } from "@tanmay/react-notify";

export default function Demo() {
  const { success, error, warning, violation, info } = useNotification();

  return (
    <div>
      <button onClick={() => success("Saved successfully!")}>Success</button>
      <button onClick={() => error("Something went wrong!")}>Error</button>
      <button onClick={() => warning("This action is risky!")}>Warning</button>
      <button onClick={() => violation("Policy violation detected!")}>Violation</button>
      <button onClick={() => info("Welcome back!")}>Info</button>
    </div>
  );
}

Notification Types (Examples)

Success

success("Profile updated successfully");

Error

error("Failed to save data");

Warning

warning("You are about to delete this item");

Violation (Security / Proctoring use-case)

violation("Face not detected. Please return to screen.");

ℹ Info

info("New update available");

Custom Options

Custom duration

success("Auto closes in 2 seconds", { duration: 2000 });

Persistent notification

info("Uploading file...", { duration: null });

Hide close button

info("Processing...", { duration: null, showClose: false });

Custom position (per toast)

error("Server unreachable", { position: "bottom-left" });

Supported positions

  • top-right
  • top-left
  • bottom-right
  • bottom-left
  • top-center
  • bottom-center

Unique Feature 1: Workflow / Loading Toasts (ID-based)

You can manually control notifications using IDs.

const id = addNotification({
  type: "info",
  message: "Saving data...",
  duration: null,
  showClose: false
});

// later
removeNotification(id);

Useful for:

  • Long-running tasks
  • Proctor engine startup
  • Uploads
  • Payments

Unique Feature 2: promise() Helper

This is the most powerful feature of the system.

It automatically handles:

  • Loading state
  • Success state
  • Error state

Basic Usage

const { promise } = useNotification();

promise(
  fetch("/api/save"),
  {
    loading: "Saving data...",
    success: "Saved successfully!",
    error: "Save failed"
  }
);

Axios Example (Real-world)

import axios from "axios";
import { useNotification } from "@tanmay/react-notify";

export default function SaveButton() {
  const { promise } = useNotification();

  const save = () => {
    promise(
      axios.post("/api/save", { name: "Tanmay" }),
      {
        loading: "Saving data...",
        success: "Data saved!",
        error: "Save failed!"
      }
    );
  };

  return <button onClick={save}>Save</button>;
}

Advanced promise() Usage (dynamic messages)

promise(
  axios.post("/api/upload"),
  {
    loading: "Uploading file...",
    success: (res) => `Uploaded ${res.data.fileName}`,
    error: (err) => err.response?.data?.message || "Upload failed"
  }
);

How promise() Works

  1. Shows a persistent loading toast
  2. Waits for the promise to resolve or reject
  3. Automatically removes loading toast
  4. Shows success OR error toast
  5. Returns the original promise result

No manual cleanup required.


API Reference

useNotification() returns

| Method | Description | | ------------------------------ | ----------------------------------------- | | addNotification(options) | Create custom notification (returns id) | | removeNotification(id) | Remove a notification | | clearAll() | Clear all notifications | | success(message, options?) | Success toast | | error(message, options?) | Error toast | | warning(message, options?) | Warning toast | | violation(message, options?) | Violation toast | | info(message, options?) | Info toast | | promise(promise, config) | Async workflow helper |


promise(promise, config)

Config object

| Key | Type | Description | | --------- | ----------------- | --------------- | | loading | string | Loading message | | success | string | function | Success message | | error | string | function | Error message |


Design Philosophy

  • Market-standard UI
  • Predictable behavior
  • No external dependencies
  • Built for production workflows
  • Easy to extend

📄 License

MIT © Tanmay Seth