
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@boxfish-studio/react-notification-manager
Advanced tools
$ npm i @boxfish-studio/react-notification-manager
or yarn
$ yarn add @boxfish-studio/react-notification-manager
NotificationProvider:import { NotificationProvider } from '@boxfish-studio/react-notification-manager'
<NotificationProvider>
<App />
</NotificationProvider>
NotificationManager and place it in your layout:import { NotificationManager } from '@boxfish-studio/react-notification-manager'
const Layout = () => {
return (
<div>
// ...
<NotificationManager />
</div>
)
}
useNotification hook:import { useNotification, type NotificationType } from '@boxfish-studio/react-notification-manager'
const Button = () => {
const { showNotification } = useNotification()
const addNotification = () => {
showNotification({
message: "I'm a toast!",
type: NotificationType.Info,
duration: 5000, // Optional
})
}
return <button onClick={addNotification}>Click on me to show a notification!</button>
}
The NotificationManager component accepts a configuration prop to allow you to customize your notifications.
Custom configuration must be of type INotificationConfiguration. All available props are shown below:
interface INotificationConfiguration {
hasIcon?: boolean
icons?: {
[key in NotificationType]?: string
}
}
enum NotificationType {
Success = 'success',
Error = 'error',
Warning = 'warning',
Info = 'info',
}
| Name | Description |
|---|---|
| hasIcon | If the Notification should contain an icon |
| icons | An object with the notification type as key, and an image url as a value. |
Example:
import { NotificationManager, type INotificationConfiguration } from '@boxfish-studio/react-notification-manager'
const Layout = () => {
// Optional configuration
const configuration: INotificationConfiguration = {
hasIcon: true,
icons: {
warning: '/custom-warning-icon.svg',
},
}
return (
// ...
<NotificationManager configuration={configuration} />
)
}
All the elements of the components contain classes that you can point to in your styles to customize the appearance of the notifications, just override the styles in your global css file.
Example:
.notification-manager {
bottom: 2rem;
left: 2rem;
/* To remove the default right position */
right: unset;
.notification__toast {
border-radius: 8px;
}
.notification--warning {
background-color: #f58223;
}
.notification__message {
color: black;
font-size: 18px;
font-weight: 500;
}
}
The useNotification hook returns three functions:
const { showNotification, removeNotification, updateNotification } = useNotification()
showNotification({
message: "I'm a toast!",
type: NotificationType.Info,
duration: 5000, // Optional
})
| Name | type | Description | Required |
|---|---|---|---|
| message | string | The message that will show up in the notification. | true |
| type | NotificationType | The type of the notification. This will change then icon and classes in the notification. | true |
| duration | number | Duration in milliseconds that will last the toast until the user closes it. Use 0 to make it infinite. |
removeNotification(id)
updateNotification(id, {
message: 'ERROR!',
type: NotificationType.Error,
duration: 0, // Doesn't close automatically.
})
The useNotification hook also returns an array with all the notifications. This array is of type INotification[].
You can use this array to manage your notifications whenever you want.
const { notifications } = useNotification()
interface INotification {
id: string
message: string
type: NotificationType
duration?: number
}
FAQs
Notification Manager for React
We found that @boxfish-studio/react-notification-manager demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.