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

@mshafiqyajid/react-toast

v0.4.2

Published

Headless toast hook and styled provider for React. Context-free pub/sub store, typed, animated, SSR-safe, dark mode, fully accessible.

Readme

@mshafiqyajid/react-toast

A toast notification system for React with a context-free pub/sub API.

Full docs →

Install

npm install @mshafiqyajid/react-toast

Quick start (styled)

import { ToastProvider } from "@mshafiqyajid/react-toast/styled";
import "@mshafiqyajid/react-toast/styles.css";
import { useToast } from "@mshafiqyajid/react-toast";

function App() {
  return (
    <>
      <ToastProvider position="bottom-right" duration={4000} />
      <Page />
    </>
  );
}

function Page() {
  const { toast } = useToast();
  return (
    <button onClick={() => toast.success("Saved!")}>
      Save
    </button>
  );
}

API

useToast()

Returns { toast, dismiss, dismissAll }.

const { toast, dismiss, dismissAll } = useToast();

// Basic
const id = toast("Hello world");
const id = toast("Custom", { type: "success", duration: 3000 });

// Convenience methods
toast.success("Saved successfully");
toast.error("Something went wrong");
toast.warning("Low disk space");
toast.info("Update available");
toast.loading("Saving…");

// Promise-driven lifecycle (loading → success | error)
toast.promise(saveProfile(), {
  loading: "Saving profile…",
  success: (user) => `Saved ${user.name}`,
  error:   (err)  => `Failed: ${(err as Error).message}`,
});

// Update an existing toast in-place (no close/reopen)
const id = toast.loading("Uploading…");
toast.update(id, { message: "Upload complete!", type: "success" });

// Channel routing — only appears in <ToastProvider channel="notifications">
toast.channel("notifications").success("New message received");

// Persistent toast (no auto-dismiss)
toast("This stays until dismissed", { duration: 0 });

// Progress ring
toast("Doing work…", { duration: 6000, showProgress: true });

// Dismiss
dismiss(id);
dismissAll();

toast (standalone)

Also exported as a top-level binding so non-React code can fire toasts:

import { toast } from "@mshafiqyajid/react-toast";
toast.error("Caught outside React");

useToasts()

Returns the current list of active toasts. Use this to build a custom renderer.

const toasts = useToasts();

Toast options

Pass as the second argument to toast(message, options):

| Option | Type | Default | Description | |--------|------|---------|-------------| | type | "neutral" \| "success" \| "error" \| "warning" \| "info" \| "loading" | "neutral" | Visual variant | | title | string | — | Bold heading rendered above the message | | duration | number (ms) | 4000 | Auto-dismiss timeout. 0 or Infinity keeps the toast open forever. | | action | { label, onClick } | — | Action button rendered in the toast | | id | string | — | Pre-supplied id, useful for updating an existing toast | | showProgress | boolean | — | When true and duration > 0, shows a circular SVG countdown ring instead of the flat bar. | | channel | string | "default" | Route to a specific <ToastProvider channel="...">. |

Example with title + action:

toast("Profile updated", {
  type: "success",
  title: "Saved",
  action: { label: "Undo", onClick: () => revert() },
  duration: 6000,
});

<ToastProvider>

Place once near the root of your app. Renders toasts into a document.body portal.

| Prop | Type | Default | |------|------|---------| | position | "top-left" \| "top-center" \| "top-right" \| "bottom-left" \| "bottom-center" \| "bottom-right" | "bottom-right" | | maxToasts | number | 5 | | duration | number (ms) | 4000 | | channel | string | "default" | Only renders toasts dispatched to this channel. |

Dark mode

Set data-theme="dark" on any ancestor element:

<html data-theme="dark">

License

MIT

What's new in 0.4.0

  • toast.update(id, partial) — update an existing toast in-place without closing it. Pass any subset of { message, type, title, duration, action, showProgress }. The body fades in briefly on change. Ideal for "Uploading… → Upload complete!" patterns. Every toast.* call returns the id.
  • Persistent toastsduration: 0 (or Infinity) keeps a toast open forever; no auto-dismiss. Existing toast.loading() already uses Infinity.
  • Progress ring — set showProgress: true on any toast with duration > 0 to show a circular SVG countdown ring (rtoast-ring CSS class) in place of the flat progress bar.
  • Channel routing<ToastProvider channel="notifications" /> renders only toasts sent to that channel. Use toast.channel("notifications").success("…") to target it. Default channel is "default" — existing code without a channel is unchanged.

What's new in 0.3.0

  • Swipe-to-dismiss — touch-drag a toast horizontally to dismiss; threshold ~80 px. Per-toast opt-out via dismissibleSwipe: false.
  • Undo with countdown ring — toasts with undo: () => void render a circular SVG progress that counts down from duration; clicking it cancels and dismisses.
  • Pause-on-hover — hovering any toast pauses every toast's auto-dismiss timer. <ToastProvider pauseOnHover> (default true).
  • action.variantaction: { label, onClick, variant?: "primary" | "outline" | "ghost" }.
  • Draggable region<ToastProvider draggable positionStorageKey="..."> exposes a small handle; users can drag the entire stack to a different corner; the choice is persisted.