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

toastware

v2.0.2

Published

A lightweight React toast notification library with animations and custom styles.

Readme

🍞 toastware

A lightweight, customizable, and developer-friendly toast notification system for React.


✨ Features

  • 🔥 Multiple positions support (top-right, top-left, bottom-right, bottom-left)
  • ⏳ Built-in auto-dismiss with smooth progress bar
  • 🖱 Pause on hover
  • 🎨 Fully customizable with CSS classes
  • 📦 Tiny footprint and zero external dependencies

📦 Installation

npm install toastware
# or
yarn add toastware

⚡ Quick Start

1. Wrap your app with ToastProvider

import { ToastProvider } from "toastware";

function App() {
  return (
    <ToastProvider>
      <YourApp />
    </ToastProvider>
  );
}

Global Toast API (No Hooks Needed)

You can now use Toastware globally without importing or calling the useToast() hook in your React components. Simply import the toastware object and start triggering toasts anywhere in your app — even outside React components!

✅ Example Usage

import toastware from "toastware";

function App() {
  return (
    <div>
      <button onClick={() => toastware.success("Operation successful!")}>
        Show Success Toast
      </button>
      <button onClick={() => toastware.error("Something went wrong!")}>
        Show Error Toast
      </button>
      <button onClick={() => toastware.addToast("Custom message", "info", "top-left")}>
        Custom Toast
      </button>
    </div>
  );
}

📦 Available Methods

| Method | Description | Example | | -------------------------------------------------------- | ------------------------------------- | ---------------------------------------------------- | | toastware.addToast(message, type?, position?, duration?) | Adds a custom toast with full control | toastware.addToast("Saved!", "success", "top-right") | | toastware.notify(message, type?, position?, duration?)|Alias for addToast()| toastware.notify("Saved!", "success", "top-right")| | toastware.success(message, position?) | Shows a success toast | toastware.success("Profile updated!") | | toastware.error(message, position?) | Shows an error toast | toastware.error("Network error!") | | toastware.warning(message, position?) | Shows an warning toast | toastware.warning("Warning : message!") || | toastware.info(message, position?) | Shows an info toast | toastware.info("New update available") | | toastware.removeToastById(id) | Removes a specific toast by ID | — | | toastware.clearToasts() | Clears all toasts | toastware.clearToasts() | | toastware.clear() | Alias for clearToasts() | toastware.clear() |


⏳ Promise-Based Toasts

Toastware now supports promise-based toast notifications — perfect for async tasks like API calls or file uploads.

Example:

toaster.promise(fetch("/api/user"), {
  loading: "Fetching user data...",
  success: "User loaded successfully!",
  error: "Failed to fetch user data.",
});

Promise API

| Key | Type | Description | | --------- | ------ | -------------------------------------- | | loading | string | Message shown while promise is pending | | success | string | Message shown when promise resolves | | error | string | Message shown when promise rejects |



2. Use the useToast hook

import { useToast } from "toastware";

function DemoButton() {
  const { addToast } = useToast();

  return (
    <button
      onClick={() =>
        addToast({
          message: "Hello World!",
          type: "success",
          position: "top-right",
          duration: 3000,
        })
      }
    >
      Show Toast
    </button>
  );
}

🛠 API Reference

ToastProvider

  • Wraps your app and manages state of all toasts.

  • Props (optional):

    • defaultPosition"top-right" | "top-left" | "bottom-right" | "bottom-left" (default: "top-right")
    • defaultDuration → number in ms (default: 3000)

useToast

Hook that gives you access to toast actions.

const { addToast, removeToast, clearToasts } = useToast();
  • addToast(options: ToastItem) → Adds a toast.

    • message: string – text to show
    • type: "info" | "success" | "warning" | "error"
    • position?: string
    • duration?: number (ms)
  • removeToast(id: string | number) → Manually removes a toast.

  • clearToasts() → Removes all active toasts.


ToastItem Type

type ToastItem = {
  id?: string | number;
  message: string;
  type?: "info" | "success" | "warning" | "error";
  position?: "top-right" | "top-left" | "bottom-right" | "bottom-left";
  duration?: number;
};

🎨 Styling

Default classes provided:

  • .toast-container – wrapper for each position group
  • .toast – base toast style
  • .toast-content – content area
  • .toast-close – close button
  • .toast-progress – progress bar

👉 You can override or extend styles by importing your own CSS.


💡 Best Practices

  • Use position to avoid overlapping with app UI.
  • Keep messages short and clear.
  • For error messages, prefer duration: 5000 for better visibility.
  • Don’t overload user with too many toasts simultaneously.

🧪 Example

addToast({
  message: "Profile updated successfully!",
  type: "success",
  position: "bottom-left",
  duration: 4000,
});

📖 License

MIT © Amresh Maurya