Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-hot-toast

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hot-toast

Smoking hot React Notifications. Lightweight, customizable and beautiful by default.

  • 2.4.1
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is react-hot-toast?

react-hot-toast is a lightweight and customizable toast notification library for React applications. It provides a simple API to create and manage toast notifications with various customization options.

What are react-hot-toast's main functionalities?

Basic Toast Notification

This feature allows you to display a basic toast notification with a simple message. The `Toaster` component is used to render the toast notifications.

import toast, { Toaster } from 'react-hot-toast';

function App() {
  return (
    <div>
      <button onClick={() => toast('Hello, World!')}>Show Toast</button>
      <Toaster />
    </div>
  );
}

Custom Toast Notification

This feature allows you to customize the toast notification with various options such as duration, position, and styles.

import toast, { Toaster } from 'react-hot-toast';

function App() {
  return (
    <div>
      <button onClick={() => toast('Custom Toast', {
        duration: 4000,
        position: 'top-center',
        style: {
          background: '#333',
          color: '#fff',
        },
      })}>Show Custom Toast</button>
      <Toaster />
    </div>
  );
}

Promise-based Toast Notification

This feature allows you to display toast notifications based on the state of a promise. It shows different messages for loading, success, and error states.

import toast, { Toaster } from 'react-hot-toast';

function App() {
  const handleClick = () => {
    const myPromise = new Promise((resolve, reject) => {
      setTimeout(() => resolve('Success!'), 2000);
    });

    toast.promise(myPromise, {
      loading: 'Loading...',
      success: 'Success!',
      error: 'Error!',
    });
  };

  return (
    <div>
      <button onClick={handleClick}>Show Promise Toast</button>
      <Toaster />
    </div>
  );
}

Other packages similar to react-hot-toast

Keywords

FAQs

Package last updated on 28 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc