react-hot-toast is a highly regarded, lightweight, and customizable React notification library designed to display "smoking hot" toast messages with minimal setup and a beautiful default aesthetic. Currently stable at version 2.6.0, the package maintains an active and responsive release cadence, frequently introducing new features and performance enhancements. Notable recent updates include support for multiple toasters in v2.6.0, enhanced React Server Components (RSC) compatibility for Next.js 13 App Router in v2.4.1, and significant bundle optimizations in v2.3.0. Its key differentiators include a powerful Promise API that automatically handles loading, success, and error states, an exceptionally small bundle size of less than 5kb, and versatile headless hooks (`useToaster`) for developers requiring complete control over the UI. The library is built with accessibility in mind and ships with TypeScript types, promoting robust and type-safe development practices. It provides a simple `Toaster` component and a `toast` function that can be called anywhere in your application.
npm install react-hot-toastVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to integrate `react-hot-toast` by adding the `Toaster` component once to your application and then triggering notifications using the `toast` function from any part of your code. It shows a basic button click initiating a simple toast.
Ensure your project's bundler (e.g., Webpack, Rollup, Next.js) is configured to correctly handle ES Modules (`.mjs` files) and check your `package.json` resolutions if issues arise. Prefer ESM `import` statements over CommonJS `require`.
Add `'use client'` at the top of any component file where `react-hot-toast` components or hooks are used, particularly within a Next.js App Router context.
Upgrade to `react-hot-toast@2.5.1` or newer to automatically include `csstype` as a dependency and resolve potential warnings.
Review your application's multi-toaster logic. If you were manually managing multiple `Toaster` instances, consider adopting the `id` prop on `Toaster` and the new `dismissAll(id?)` and `removeAll(id?)` functions for better control and integration.
For headless use cases, explicitly import from `react-hot-toast/headless` if you were previously relying on other internal paths or if you experience build issues related to headless functionality.
Refactor your imports to use ES Module syntax (e.g., `import toast from 'react-hot-toast';`) and ensure your build tools are configured for ESM.
Upgrade `react-hot-toast` to version `2.4.0` or higher, which includes a fix for this infinite loop during testing.
Ensure your promise resolution/rejection consistently provides an object with a `message` property for clear toast display, especially for older versions. Upgrade to `v2.5.1` or newer, which improved `toast.promise()` to make messages truly optional and allow async functions.