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

sonner-js

v1.1.3

Published

An opinionated toast component for Pure JS.

Readme

npm version npm downloads License: MIT


✨ Features

  • 🚀 Zero Dependencies - Pure JavaScript implementation, no frameworks required
  • 📱 Responsive Design - Perfect adaptation for mobile and desktop
  • 🎨 Multiple Styles - Support for success, error, warning, info and more types
  • Lightweight - Small bundle size with excellent performance
  • 🔧 Highly Customizable - Rich configuration options
  • 🌙 Theme Support - Built-in light and dark themes
  • 📦 Multi-format Support - UMD, ESM, CommonJS formats

🚀 Quick Start

Installation

npm install sonner-js

Basic Usage

import toast from 'sonner-js';

// Simple toast
toast('Hello World!');

// Toast with description
toast('Operation successful', {
    description: 'Your data has been saved'
});

📖 Usage Guide

Different Toast Types

// Success toast
toast.success('Operation successful');

// Error toast
toast.error('Operation failed');

// Info toast
toast.info('This is an information');

// Warning toast
toast.warning('Please note');

Toast with Action Buttons

toast('Confirm action', {
    action: {
        label: 'Confirm',
        onClick: () => console.log('User clicked confirm')
    }
});

// With cancel button
toast('Confirm deletion', {
    action: {
        label: 'Cancel',
        onClick: () => console.log('User cancelled operation'),
        cancel: true
    }
});

Promise Handling

const fetchData = () => fetch('/api/data');

toast.promise(fetchData, {
    loading: 'Loading...',
    success: 'Data loaded successfully',
    error: 'Failed to load data'
});

Update and Dismiss Toasts

// Create toast and get ID
const toastId = toast('Processing...');

// Update toast
toast.success('Processing complete', { id: toastId });

// Dismiss specific toast
toast.dismiss(toastId);

// Dismiss all toasts
toast.dismiss();

Permanent Toasts

toast('Important notice', {
    duration: 0  // Set to 0 for permanent display
});

🌐 CDN Usage

UMD Format

<script src="https://cdn.jsdelivr.net/npm/sonner-js/dist/umd/index.min.js"></script>
<script>
    sonnerJS('Hello from CDN!');
</script>

ESM Format

<script type="module">
    import toast from 'https://cdn.jsdelivr.net/npm/sonner-js/+esm';
    toast('Hello from ESM!');
</script>

⚙️ Configuration Options

import toast from 'sonner-js';

// Global configuration
toast.config({
    theme: 'dark',           // 'light' | 'dark'
    position: 'top-right',   // Position
    duration: 4000,         // Duration in milliseconds
    closeButton: true,      // Show close button
    richColors: true,        // Rich colors
    expand: true,           // Expand animation
    visibleToasts: 3,       // Number of visible toasts
    gap: 8,                 // Toast spacing
    offset: 16,             // Margin
    mobileOffset: 16,       // Mobile margin
    dir: 'ltr'              // Text direction
});

📄 License

MIT License - see LICENSE file for details.