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

next-toast

v1.0.3

Published

A lightweight toast notification system for Next.js and React.

Readme

NextToast

NextToast is a lightweight, flexible toast notification system for React and Next.js. It is designed to be simple to use, fully customizable, and safe for client components.

It supports standard notifications, loading states, confirmations, promises, and fully custom React components.


Features

  • Works with Next.js App Router and React
  • Simple global API (toast.success, toast.error, etc.)
  • Rich or plain styling modes
  • Confirmation toasts with actions
  • Promise-based toasts
  • Supports ReactNode everywhere (not just strings)
  • Configurable close button behavior
  • Automatic stacking and dismissal
  • Accessible (ARIA roles included)
  • No external dependencies

Installation

Copy the source files into your project or install from your package source.


Basic Usage

Mount the toast container once in your app layout:

import { NextToast } from "./next-toast";

export default function RootLayout({ children }) {
  return (
    <>
      {children}
      <NextToast />
    </>
  );
}

Trigger a toast from anywhere:

import { toast } from "./toast-store";

toast.success("Saved successfully");
toast.error("Something went wrong");
toast.info("New update available");

Toast Types

Supported types:

  • success
  • error
  • info
  • loading
  • default
  • custom

Rich vs Plain Mode

You can control visual style using the richColors prop.

<NextToast richColors={true} />
  • richColors={false} → white background, black border, black text
  • richColors={true} → semantic colors (success, error, info, loading)

Close Button Control

Global control:

<NextToast position="top-right" richColors={false} closeButton={true} />

Per-toast control:

toast.info("Closable toast", { dismissible: true });

A toast will show the close button only if:

  • closeButton is enabled on <NextToast />
  • dismissible is true for that toast

Confirmation Toasts

Confirmation toasts support React components, not just strings.

toast.confirm(
  <div>
    <strong>Delete item?</strong>
    <div>This action cannot be undone.</div>
  </div>,
  () => {
    console.log("Confirmed");
  },
  {
    label: "Delete",
    cancelLabel: "Cancel",
    dismissible: true,
  }
);

Confirmation Options

| Option | Type | Description | | ------------- | --------- | ---------------------- | | label | ReactNode | Confirm button content | | cancelLabel | ReactNode | Cancel button content | | dismissible | boolean | Enables close button | | duration | number | Auto dismiss time |


Promise Toasts

Handle async flows easily:

toast.promise(
  fetch("/api/save"),
  {
    loading: "Saving...",
    success: "Saved",
    error: "Failed",
  }
);

The toast updates automatically based on promise state.


Custom Toasts

Render anything you want:

toast.custom((t) => (
  <div>
    <h4>Custom Content</h4>
    <button onClick={() => toast.dismiss(t.id)}>Close</button>
  </div>
));

Configuration Props

<NextToast />

| Prop | Type | Default | | ------------- | ------- | ------------ | | position | string | top-center | | richColors | boolean | true | | closeButton | boolean | true | | maxVisible | number | 4 |


Accessibility

  • Uses proper ARIA roles
  • Error toasts use role="alert"
  • Screen-reader friendly
  • Keyboard accessible close button

File Structure

src/
 ├─ next-toast.tsx
 ├─ toast-store.ts
 ├─ styles.css
index.ts

License

This project is licensed under the MIT License.

You are free to use, modify, and distribute it.


LICENSE (MIT)

MIT License

Copyright (c) 2026 rimu-7

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.