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

react-simple-toastify

v1.2.0

Published

**react-simple-toastify** is a simple library for displaying notifications in your application

Downloads

19

Readme

Getting stated with react-simple-toastify

react-simple-toastify is a simple library for displaying notifications in your application

Installation

For installing this library you should use npm.

npm install react-simple-toastify

or

npm i react-simple-toastify

Usage

It's very simple to setup this library, you have to follow the following steps below.

Step 1.

You have to import and set up one Provider of context in your application, where you want to display toasts. Assuming that you have an App component which is your main component that contains all the rest of yours other components. You must put all other elements or components inside a Provider component named 'ToastProdvider', which contains global declaration of data that will be access anywhere in the app.

Import

import {ToastProvider} from 'react-simple-toastify'

Creation of App component and setup the Provider


const App = () => {
  return (
    <ToastProvider>
      {
        // here you can put anything you want...
      }
    <ToastProvider>
  )
}

export default App

Step 2.

Now, you need to add some options prop to the ToastProvider. This component takes only one prop.

Set up Let's consider the following options


const toastOptions = {
  position: "top" || "center" || "bottom",
  timeout: 1000
}

Explanation of the Option | properties | type | default | description | | --- | --- | --- | --- | | position | String | "bottom" | set the position of the toast on the screen | | timeout | Number | 1000 | set the delay time before masking the toast |

Insertion of options to the ToastProvider Component


const App = () => {
  // some options
  const toastOptions = {
    position: "bottom",
    timeout: 1000
  }

  return (
    <ToastProvider options={toastOptions}>
      {
        // here you can put anything you want...
      }
    <ToastProvider>
  )
}

export default App

It's ok, you have correctly setup the toast system in your application, Congrats ... Now, you can display toast everywhere in your application

Step 3.

Now, you are ready to display toast. Suppose that you have another component named TestComponent. Let's see how we can easily display toast.

With Function component

import React, {useContext} from 'react'
import {ToastContext} from 'react-simple-toastify'

const TestComponent = () => {
  /**
   * Here we destructure the displayToast from ToastContext
   **/
  const {displayToast} = useContext(ToastContext)

  return (
    <div>
      {
        // other elements here
      }

      <button onClick={() => displayToast("Hello World !")}>display Toast</button>
    </div>
  )
}

export default TestComponent

With Class Component

import React from 'react'
import {ToastContext} from 'react-simple-toastify'

class TestComponent extends React.Component {
  render() {
    const {displayToast} = this.context

    return (
      <div>
        {
          // other elements here
        }

        <button onClick={() => displayToast("Hello World !")}>display Toast</button>
      </div>
    )
  }
}

TestComponent.contextType = ToastContext

export default TestComponent

Explanation

When you call the displayToast() function, by passing the message as argument, the toast will be displayed and will disappear after the number of milliseconds define in the configuration of the ToastProvider. This function takes only one argument, which is the message to display.