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

snack-alert

v1.0.17

Published

A simple React toast notification library with Tailwind CSS

Readme

🥪 SnackAlert

Simple, beautiful toast-style alert system for React. Easy to use. Easy to love.

SnackAlert provides a flexible, lightweight, and customizable way to show toast/snackbar-style notifications in your React app using a modern hook-based API.

📦 Installation

npm install snackalert
# or
yarn add snackalert

🚀 Quick Start

SnackAlert gives you two powerful ways to get started instantly — automatic injection or app wrapping — with no extra setup.

🧩 Option 1: Use withSnackAlert HOC

Prefer manual control over your root app? Wrap it cleanly with the withSnackAlert helper.

// main.tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import { App } from './App';

import 'snack-alert/css';
import { withSnackAlert } from 'snack-alert';

const AppWithAlerts = withSnackAlert(App);

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <AppWithAlerts />
  </React.StrictMode>
);

🧩 Option 2: Auto-Mount Anywhere (Zero Config)

Perfect for static apps, SPAs, or dashboards — SnackAlert mounts itself globally.

import 'snack-alert/css';
import { mountSnackAlert } from 'snack-alert';

// Mount the alert system into the DOM (usually called once at app start)
mountSnackAlert();

Now you can trigger alerts anywhere using the useAlert hook:

import { useAlert, AlertType } from 'snack-alert';

const MyComponent = () => {
  const { showAlert } = useAlert();

  return (
    <button
      onClick={() => showAlert({
          type: AlertType.INFO,
          message: "🥪 SNACK ALERT!!! Have you had a snack today?"
        })
      }
    >
      Show Alert
    </button>
  );
};

✅ What’s Exported

// snackalert package
export { useAlert } from 'snack-alert';
export { AlertType, mountSnackAlert, withSnackAlert } from 'snack-alert';

2. Use the useAlert hook

import { useAlert, AlertType } from 'snack-alert';

const MyComponent = () => {
  const { showAlert } = useAlert();

  const handleClick = () => {
    showAlert({
      type: AlertType.INFO,
      message: "🥪 SNACK ALERT!!! Have you had a snack today?"
    });
  };

  return (
    <button onClick={handleClick}>
      Show SnackAlert
    </button>
  );
};

🧠 API Reference

useAlert()

Hook that provides alert functionality in your component.

Returns

  • showAlert(options: ShowAlertOptions): void

showAlert Options

| Option | Type | Required | Description | | ---------- | ----------- | -------- | ----------------------------------------------------- | | type | AlertType | ✅ | Type of alert: INFO, SUCCESS, WARNING, ERROR | | message | string | ✅ | Text to display in the alert | | duration | number | ❌ | Time in milliseconds before dismiss (default: 3000ms) |

🎨 AlertType Enum

enum AlertType {
  INFO = 'info',
  SUCCESS = 'success',
  WARNING = 'warning',
  ERROR = 'error'
}

📂 Exports

// index.ts
export { AlertType } from './main.tsx';
export { useAlert } from './core/hooks/provider.ts';

✨ Features

  • ⚡ One-line usage with useAlert()
  • 💅 Clean, auto-dismiss toasts with type styling
  • 🔁 Option to customize duration and styles
  • 🧱 Zero dependencies, built with modern React
  • 🧪 Ready for unit & integration testing

🛠️ Customization (Coming Soon)

  • Theming (light/dark/custom)
  • Custom icons per alert type
  • Toast positioning
  • Global config

📸 Demo

🧪 Example Use Case

showAlert({
  type: AlertType.SUCCESS,
  message: "✅ Order placed successfully!",
  duration: 5000
});

🧩 Folder Structure (if using from source)

snackalert/
├── core/
│   └── hooks/
│       └── provider.ts
├── main.tsx
└── index.ts

🧑‍💻 Contributing

Feel free to open issues or PRs for features, bugs, or enhancements. We'd love your input to make SnackAlert the best toast solution out there.

🧾 License

MIT License © 2025 Emmanuel Bankole

❤️ Inspired By

📬 Contact

For questions or feedback, reach out via GitHub Issues or email