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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-snackbars-stack

v1.0.1

Published

A simple and flexible stackable snackbars for React

Downloads

117

Readme

React Snackbars Stack

Description

React Snackbars Stack is a flexible and easy-to-use library for displaying snackbars in your React applications. It provides a simple API to show notifications with different severities and customizable options. Whether you need to show a single snackbar or manage a stack of multiple snackbars, this library has you covered.

Installation

Install the package using npm or yarn:

npm install react-snackbars-stack
# or
yarn add react-snackbars-stack

Usage

Option 1: Direct Use

Import the SnackbarProvider and wrap your application with it. Use the enqueueSnackbar method to show snackbars.

🚀 Important Note: You don't need to wrap your entire application with the SnackbarProvider context. You can use it directly in any component by placing it inside the render method, such as the return statement in a function component or the render method in a class component.

import React from 'react';
import { SnackbarProvider, enqueueSnackbar } from 'react-snackbars-stack';

function App() {
  const handleClick = () => {
    enqueueSnackbar('This is a snackbar message!');
    // OR
    enqueueSnackbar(
      'This is a snackbar message with applied options!', 
      {
        severity:'success', // inof, success, warning, error
        preventDuplicate:true,
        duration:1500
      }
    );
  };

  return (
    <>
      <SnackbarProvider /> {/* Check API for options */}
      <button onClick={handleClick}>Show Snackbar</button>
    </>
  );
}

export default App;

Option 2: Using Hook

Wrap your root app or a specific parent app with the SnackbarProvider context. Import the hook in a child component to use the method to show snackbars.

import React from 'react';
import { SnackbarProvider, useSnackbar } from 'react-snackbars-stack';

function MyComponent() {
  const { enqueueSnackbar } = useSnackbar();

  const handleClick = () => {
    enqueueSnackbar(...);
  };

  return (
    <>
      <button onClick={handleClick}>Show Snackbar</button>
    </>
  );
}

const App = () => (
  <SnackbarProvider>
    <MyComponent />
  </SnackbarProvider>
);

export default App;

NextJS support

If you're using Next.js and need to integrate the react-snackbars-stack package into your root layout (or any server component), you’ll need to handle the use client directive. This is required because the context provider relies on React hooks, which are incompatible with server components by default.

Create a Wrapper Component, e.g., SnackbarProviderWrapper.jsx, with the use client directive.

'use client';

import { SnackbarProvider } from 'react-snackbars-stack';

export default SnackbarProvider;

Screenshot

screenshot

API

enqueueSnackbar Method

The enqueueSnackbar method is used to show a snackbar notification. If there are already some snackbars being displayed, it adds the snackbar above or below the existing snackbars in the stack.

| Option | Type | Description | Default | |------------------|---------|--------------------------------------|---------| | message | string | The message to display | - | | severity | string | The severity of the message | 'info' | | preventDuplicate | boolean | Prevent duplicate messages | false | | duration | number | Duration to show the snackbar (ms) | 3000 |

SnackbarProvider Component

The SnackbarProvider component is used to wrap your application and provide the snackbar context.

| Option | Type | Description | Default | |------------------|---------|--------------------------------------|---------| | maxSnackbars | number | Maximum number of snackbars to show | 3 | | autoHideDuration | number | Duration to auto-hide the snackbar | 3000 | | icon | boolean | Hide the icon in the snackbar | true | | theme | string | Theme of the snackbar ('dark' or 'light') | 'light' | | anchorOrigin | object | Position of the snackbar | { vertical: 'bottom', horizontal: 'left' } | | transitionType | string | Transition type for the snackbar ('slide', 'grow', 'fade', 'zoom') | 'slide' |

TODO

  • [x] Custom hook support
  • [x] Theme switching (MUI based)
  • [ ] Filled icons option
  • [ ] Custom theming support
  • [ ] Custom transitions

Purpose: Created for personal use due to Notistack's outdated dependencies causing deployment issues. Published for anyone seeking an alternative to Notistack (though this package is not superior to Notistack).

Connect with Us

Feel free to reach out:

Contribution

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.