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

alertajs

v1.1.2

Published

A minimalist toast notification system for React.

Downloads

23

Readme

AlertaJs

A minimalist toast notification system for React. Alerta provides a simple and elegant way to display toast notifications, ensuring users are informed of events and actions in your application.

Features

  • 🚀 Lightweight and easy to integrate
  • 🎨 Supports different types of notifications: success, error, info, and warning
  • ⚙️ Customizable options for each toast (title, duration, callbacks)
  • ⏰ Automatic dismissal with optional visual timer
  • 📱 Responsive design with mobile support
  • 🎯 Simple API for adding and removing toasts
  • 🔄 Expandable toasts for long messages
  • 🎭 Smooth animations and hover interactions

Installation

To install Alerta, you can use npm or yarn:

# With npm
npm install alertajs

# With yarn
yarn add alertajs

Usage

1. Setup

Import the ToastBox component in your app component and specify the position for the toasts to be displayed:

import { alerta, ToastBox } from "alertajs";
// App.tsx
import React from 'react';
import { alerta, ToastBox } from "alertajs";

const App: React.FC = () => {
  return (
    <div>
      <h1>Your App</h1>
      {/* Other components */}
      <ToastBox position="top-right" />
    </div>
  );
};

export default App;

2. Using Alerta

You can use the Alerta methods in your components to show different types of notifications. Each method accepts a message and optional customization options:

import React from 'react';
import { alerta, ToastBox } from "alertajs";

const SomeComponent: React.FC = () => {
  const showSuccessToast = () => {
    alerta.success('Operation completed successfully!', {
      title: 'Success',
      duration: 3000,
    });
  };

  const showErrorToast = () => {
    alerta.error('Something went wrong.', {
      title: 'Error',
      duration: 5000,
    });
  };

  const showInfoToast = () => {
    alerta.info('Here is some information.', {
      title: 'Info',
      duration: 4000,
    });
  };

  const showWarningToast = () => {
    alerta.warning('Please be careful.', {
      title: 'Warning',
      duration: 6000,
    });
  };

  return (
    <div>
      <button onClick={showSuccessToast}>Show Success Toast</button>
      <button onClick={showErrorToast}>Show Error Toast</button>
      <button onClick={showInfoToast}>Show Info Toast</button>
      <button onClick={showWarningToast}>Show Warning Toast</button>
    </div>
  );
};

export default SomeComponent;

3. ToastBox Configuration

The ToastBox component accepts the following props:

<ToastBox 
  position="top-right" // "top-left" | "top-right" | "bottom-left" | "bottom-right"
  showTimer={true}     // Optional: Show visual timer (default: false)
/>

API

alerta

  • success(message: string, options?: Partial<ToastOptions>): Displays a success toast.
  • error(message: string, options?: Partial<ToastOptions>): Displays an error toast.
  • info(message: string, options?: Partial<ToastOptions>): Displays an informational toast.
  • warning(message: string, options?: Partial<ToastOptions>): Displays a warning toast.
  • dismissAll(): Dismisses all active toasts.

ToastOptions

interface ToastOptions {
  title?: string;        // Optional title for the toast
  duration?: number;     // Duration in milliseconds (default: 5000)
  onClose?: () => void;  // Optional callback when toast is dismissed
}

Customization

You can customize the appearance of your toasts by adding CSS styles. The library uses semantic class names for easy styling:

.toast {
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 10px;
  margin: 5px 0;
}

.toast.success {
  border-left-color: #28a745;
}

.toast.error {
  border-left-color: #dc3545;
}

.toast.info {
  border-left-color: #17a2b8;
}

.toast.warning {
  border-left-color: #ffc107;
}

Browser Support

AlertaJs supports all modern browsers and React versions 16.8.0 and above.

License

MIT License. See LICENSE for details.

Contributing

If you'd like to contribute to AlertaJs, feel free to fork the repository and submit a pull request!