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

@lookworld4/react-smart-toast

v1.0.0

Published

A zero-config, imperative toast notification system.

Readme

@lookworld4/react-smart-toast

Imperative toast notifications for React. Mount <Toaster /> once, call toast() from any module—no providers or context setup.

Features

  • Zero configuration: one component, one import for the API
  • TypeScript-first with exported types
  • ESM and CommonJS builds (exports field)
  • React is a peer dependency (not bundled—uses your app’s React)
  • No stylesheet to import: layout/colors use inline styles; enter/leave motion uses @keyframes injected into document.head when <Toaster /> mounts (keyframes cannot be expressed as inline styles)

Installation

npm install @lookworld4/react-smart-toast

Peer dependencies: react and react-dom (≥ 16.8; hooks required).

pnpm add @lookworld4/react-smart-toast
yarn add @lookworld4/react-smart-toast

Quick start

1. Render the toaster (e.g. root layout or App):

import { Toaster } from '@lookworld4/react-smart-toast';

export function App() {
  return (
    <>
      {/* your tree */}
      <Toaster />
    </>
  );
}

2. Show toasts from event handlers, loaders, or utilities:

import { toast } from '@lookworld4/react-smart-toast';

toast('Something happened');
toast.success('Saved');
toast.error('Request failed');
toast.info('Reminder');

// Stays on screen until the user closes it
toast('Important', { duration: 0 });

// Custom auto-dismiss (milliseconds; default is 3000)
toast('Quick note', { duration: 1500 });
toast.error('Oops', 5000); // shorthand on helpers: second arg is duration

API

<Toaster />

Renders the stack of toasts (bottom-right). Include one instance in your app.

Motion. On mount, the toaster inserts a singleton <style id="react-smart-toast-keyframes"> into <head> with slide-in (appear) and slide-out (dismiss) keyframes. Toasts animate in when shown and animate out before they are removed (including auto-dismiss after duration). The tag is removed when all <Toaster /> instances have unmounted (ref-counted, so Strict Mode/dev remount behaves correctly).

Accessibility. prefers-reduced-motion: reduce collapses animation duration so exits still complete cleanly without a long sliding effect.

Advanced note: each toast surface also uses the class react-smart-toast-item for that media query—you can scope overrides in your own CSS if needed.

toast(message, options?)

| Argument | Type | Description | |----------|------|--------------| | message | string | Text shown in the toast | | options | ToastOptions | Optional |

ToastOptions:

  • type?: 'success' \| 'error' \| 'info' — default 'info'
  • duration?: number — auto-dismiss after this many ms; default 3000. Use 0 for no auto-dismiss.

Shorthand methods

toast.success(message, duration?);
toast.error(message, duration?);
toast.info(message, duration?);

The optional second argument sets duration only (same as passing { duration }).

Exported types

import type { Toast, ToastAPI, ToastOptions, ToastType } from '@lookworld4/react-smart-toast';
  • ToastAPI — type of the toast object (callable + success / error / info)
  • Toast — shape of a toast in UI state (includes optional exiting while the slide-out animation plays; not set when you call toast())
  • ToastType'success' | 'error' | 'info'

Development

npm install
npm run build    # outputs dist/ (CJS, ESM, .d.ts)
npm run dev      # tsup watch mode

React is external in the build; consumers must install React themselves.

License

MIT