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

better-toast-react

v0.1.1

Published

A lightweight, animated React toast library inspired by x (twitter) notification.

Readme

better-toast

A lightweight, animated React toast notification library with a dark glassmorphism design — no stylesheet to import.

npm license bundle size


Features

  • 🎨 Dark glassmorphism — frosted glass look with backdrop blur, inspired by iOS & Twitter notifications
  • 🔔 Typed toastssuccess, error, warning, info, loading, and default — each with a distinct icon badge
  • 🌀 Spring physics — powered by Motion with satisfying scale-bounce arrival and smooth stack animations
  • 🔊 Sound — optional tap sound on each toast (built-in)
  • 🔂 Stacking — up to N toasts stack with parallax peek effect
  • Progress bar — auto-closing toasts show a live countdown bar
  • 💬 Promise API — wraps any Promise with loading → success/error flow
  • Zero CSS imports — styles are injected automatically
  • 📦 Tiny — tree-shakeable ESM + CJS, React & React-DOM are peer deps

Install

npm install better-toast
# or
pnpm add better-toast
# or
yarn add better-toast

Peer deps: react >= 18 and react-dom >= 18


Quick start

1. Add <Toaster /> once in your app

// app/layout.tsx (Next.js) or App.tsx (Vite/CRA)
import { Toaster } from 'better-toast';

export default function RootLayout({ children }) {
  return (
    <>
      {children}
      <Toaster position="bottom-right" />
    </>
  );
}

2. Call toast() anywhere

import { toast } from 'better-toast';

toast('Hello world!');
toast.success('Saved successfully!');
toast.error('Something went wrong.');
toast.warning('Disk space is low.');
toast.info('A new version is available.');

// Loading — persists until you dismiss it
const id = toast.loading('Uploading…');
toast.dismiss(id);

// Promise helper
toast.promise(uploadFile(), {
  loading: 'Uploading…',
  success: 'File uploaded!',
  error: (err) => `Upload failed: ${err.message}`,
});

API

toast(message, options?)

| Option | Type | Default | Description | |---|---|---|---| | duration | number | 4000 | Auto-close delay in ms. Use Infinity to persist. | | position | ToastPosition | 'bottom-right' | Where the toast appears. | | type | ToastType | 'default' | Controls the icon badge colour. | | description | string | — | Secondary text below the message. | | icon | ReactNode | — | Custom icon inside the circle (overrides default). | | action | ToastAction | — | Action button { label, onClick }. | | id | string | auto | Use to update an existing toast. | | onDismiss | (id) => void | — | Called when the toast is manually dismissed. | | onAutoClose | (id) => void | — | Called when the toast auto-expires. | | className | string | — | Extra class on the toast element. | | style | CSSProperties | — | Inline styles on the toast element. |

toast.success / error / warning / info / loading

Same signature as toast() — shorthand methods that set type automatically.

toast.promise(promise, messages, options?)

toast.promise(myPromise, {
  loading: 'Loading…',
  success: (data) => `Done! Got ${data.count} items.`,
  error:   (err)  => `Error: ${err.message}`,
});

toast.dismiss(id) / toast.dismissAll()

Programmatically dismiss one or all toasts.

toast.update(id, message, options?)

Update an existing toast in place (or create a new one if the id is gone).


<Toaster /> props

| Prop | Type | Default | Description | |---|---|---|---| | position | ToastPosition | 'bottom-right' | Default position for all toasts. | | duration | number | 4000 | Default auto-close duration. | | visibleToasts | number | 5 | Max toasts shown at once. | | pauseOnHover | boolean | true | Pause countdown when hovering. | | closeButton | boolean | false | Show an × close button on each toast. | | className | string | — | Extra class on the container. | | style | CSSProperties | — | Inline styles on the container. |

ToastPosition

'top-left' | 'top-center' | 'top-right'
'bottom-left' | 'bottom-center' | 'bottom-right'

Customising icons

Pass any ReactNode as icon to replace the default circle content:

toast.success('Profile updated!', {
  icon: <img src="/avatar.png" style={{ width: 42, height: 42, borderRadius: '50%' }} />,
});

The type badge (colour dot) still shows in the corner based on the type.


Custom CSS variables

Override these in your own stylesheet to retheme the toasts:

:root {
  --bt-bg:            rgba(28, 28, 30, 0.72); /* Toast background */
  --bt-fg:            #f2f2f7;                /* Primary text */
  --bt-desc-fg:       rgba(235, 235, 245, 0.58); /* Description text */
  --bt-radius:        20px;                   /* Border radius */
  --bt-shadow:        0 12px 40px rgba(0,0,0,.55), 0 2px 10px rgba(0,0,0,.35);
  --bt-offset:        24px;                   /* Viewport edge offset */
  --bt-z-index:       9999;

  /* Icon badge accent colours */
  --bt-success-accent: #30d158;
  --bt-error-accent:   #ff453a;
  --bt-warning-accent: #ffd60a;
  --bt-info-accent:    #0a84ff;
}

License

MIT © abheeee03