Gathering detailed insights and metrics for react-toast-notifications
Gathering detailed insights and metrics for react-toast-notifications
Gathering detailed insights and metrics for react-toast-notifications
Gathering detailed insights and metrics for react-toast-notifications
react-hot-toast
Smoking hot React Notifications. Lightweight, customizable and beautiful by default.
sonner
An opinionated toast component for React.
react-native-toast-notifications
[![Version][version-badge]][package] [![MIT License][license-badge]][license]
react-notifications-component
React component for creating notifications on the fly
🍞 A toast notification system for react
npm install react-toast-notifications
Typescript
Module System
Node Version
NPM Version
84.7
Supply Chain
87.7
Quality
74.9
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
25,229,774
Last Day
2,211
Last Week
64,501
Last Month
343,281
Last Year
3,098,136
MIT License
2,171 Stars
91 Commits
174 Forks
14 Watchers
12 Branches
19 Contributors
Updated on Jun 25, 2025
Minified
Minified + Gzipped
Latest Version
2.5.1
Package Id
react-toast-notifications@2.5.1
Size
13.11 kB
NPM Version
6.12.1
Node Version
12.13.1
Published on
Jul 08, 2021
Cumulative downloads
Total Downloads
2
24
This was a great project to learn from and fulfilled the requirements it set out to. Unfortunately, I can no-longer give this project the time it needs. Consider react-hot-toast as an alternative, or look at the source and make your own ???? (there really isn't much to it).
A configurable, composable, toast notification system for react.
https://jossmac.github.io/react-toast-notifications
1yarn add react-toast-notifications
Wrap your app in the ToastProvider
, which provides context for the Toast
descendants.
1import { ToastProvider, useToasts } from 'react-toast-notifications'; 2 3const FormWithToasts = () => { 4 const { addToast } = useToasts(); 5 6 const onSubmit = async value => { 7 const { error } = await dataPersistenceLayer(value); 8 9 if (error) { 10 addToast(error.message, { appearance: 'error' }); 11 } else { 12 addToast('Saved Successfully', { appearance: 'success' }); 13 } 14 }; 15 16 return <form onSubmit={onSubmit}>...</form>; 17}; 18 19const App = () => ( 20 <ToastProvider> 21 <FormWithToasts /> 22 </ToastProvider> 23);
For brevity:
PlacementType
is equal to 'bottom-left' | 'bottom-center' | 'bottom-right' | 'top-left' | 'top-center' | 'top-right'
.TransitionState
is equal to 'entering' | 'entered' | 'exiting' | 'exited'
.Property | Description |
---|---|
autoDismissTimeout number | Default 5000 . The time until a toast will be dismissed automatically, in milliseconds. |
autoDismiss boolean | Default: false . Whether or not to dismiss the toast automatically after a timeout. |
children Node | Required. Your app content. |
components { ToastContainer, Toast } | Replace the underlying components. |
newestOnTop boolean | Default false . When true, insert new toasts at the top of the stack. |
placement PlacementType | Default top-right . Where, in relation to the viewport, to place the toasts. |
portalTargetSelector string | Which element to attach the container's portal to. Uses document.body when not provided. |
transitionDuration number | Default 220 . The duration of the CSS transition on the Toast component. |
Property | Description |
---|---|
appearance | Used by the default toast. One of success , error , warning , info . |
children | Required. The content of the toast notification. |
autoDismiss boolean | Inherited from ToastProvider if not provided. |
autoDismissTimeout number | Inherited from ToastProvider . |
onDismiss: Id => void | Passed in dynamically. Can be called in a custom toast to dismiss it. |
placement PlacementType | Inherited from ToastProvider . |
transitionDuration number | Inherited from ToastProvider . |
transitionState: TransitionState | Passed in dynamically. |
The useToast
hook has the following signature:
1const { 2 addToast, 3 removeToast, 4 removeAllToasts, 5 updateToast, 6 toastStack, 7} = useToasts();
The addToast
method has three arguments:
Node
.Options
object, which can take any shape you like. Options.appearance
is required when using the DefaultToast
. When departing from the default shape, you must provide an alternative, compliant Toast
component.ID
.The removeToast
method has two arguments:
ID
of the toast to remove.The removeAllToasts
method has no arguments.
The updateToast
method has three arguments:
ID
of the toast to update.Options
object, which differs slightly from the add method because it accepts a content
property.ID
.The toastStack
is an array of objects representing the current toasts, e.g.
1[ 2 { 3 content: 'Something went wrong', 4 id: 'generated-string', 5 appearance: 'error', 6 }, 7 { content: 'Item saved', id: 'generated-string', appearance: 'success' }, 8];
To bring each toast notification inline with your app, you can provide alternative components to the ToastProvider
:
1import { ToastProvider } from 'react-toast-notifications'; 2 3const MyCustomToast = ({ appearance, children }) => ( 4 <div style={{ background: appearance === 'error' ? 'red' : 'green' }}> 5 {children} 6 </div> 7); 8 9const App = () => ( 10 <ToastProvider components={{ Toast: MyCustomToast }}>...</ToastProvider> 11);
To customize the existing component instead of creating a new one, you may import DefaultToast
:
1import { DefaultToast } from 'react-toast-notifications'; 2export const MyCustomToast = ({ children, ...props }) => ( 3 <DefaultToast {...props}> 4 <SomethingSpecial>{children}</SomethingSpecial> 5 </DefaultToast> 6);
This library may not meet your needs. Here are some alternative I came across whilst searching for this solution:
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 11/28 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
126 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreLast Day
-58.8%
2,211
Compared to previous day
Last Week
-29.1%
64,501
Compared to previous week
Last Month
7.8%
343,281
Compared to previous month
Last Year
1.1%
3,098,136
Compared to previous year