
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
@commercetools-frontend/notifications
Advanced tools
A general-purpose notification system built on top of redux
A general-purpose notification system built on top of redux.
$ npm install --save @commercetools-frontend/notifications
addNotification(notification, [options])notification (Object): This notification will get added to the list. See
Notification.[options] (Object): If specified, further customizes the behavior of the
notification.[dismissAfter = 0] (Number): dismiss the component after this duration
(milliseconds)[onDismiss] (Function): Callback which will get called with the
notification's id before it is dismissed.The payload must be a Notification object. The id will be added by the
middleware automatically.
After dispatching a notification to the middleware a notificationHandle will
be returned.
{
id: Number,
dismiss: Function,
}
{
id: Number,
}
A notification in the state will always have an id which gets added by the
middleware automatically, plus any props passed as the payload on creation.
{
type: 'ADD_NOTIFICATION',
payload: Object,
meta: {
dismissAfter: Number
}
}
removeNotification(id)id (Number): This notification will be removed{
type: 'REMOVE_NOTIFICATION',
payload: Number,
}
The middleware
id to every notificationdismissAfternotificationHandle for each dispatched notification containing its
id and a dismiss function for convenience.import { createStore, applyMiddleware } from 'redux';
import { middleware as notificationsMiddleware } from '@commercetools-frontend/notifications';
import rootReducer from './reducers';
// Note: this API requires redux@>=3.1.0
const store = createStore(
rootReducer,
applyMiddleware(notificationsMiddleware)
);
Mount the reducer on your notifications store slice.
reducercombineReducers({
notifications: reducer,
...more reducers here...
})
Although not required for use in the application, these are exported as well.
ADD_NOTIFICATIONREMOVE_NOTIFICATIONThey can be used for filtering out notification actions in the logger.
import React from 'react'
import PropTypes from 'prop-types';
import { removeNotification } from '@commercetools-frontend/notifications'
// Accepts a notification map function,
// which returns the component based on the notification.
//
// function mapNotificationToComponent (notification) {
// const map = {
// 'success': SuccessNotification,
// 'intercom': IntercomNotification,
// }
// return map[notification.kind] || InfoNotification
// }
//
// accept notifications, which should come from connecting to the store
class LeftNavigation extends React.PureComponent {
static propTypes: {
notifications: PropTypes.arrayOf(PropTypes.object).isRequired,
mapNotificationToComponent: PropTypes.func.isRequired,
};
render () {
return (
<div>
{
this.props.notifications.map(
notification => {
const Component = this.props.mapNotificationToComponent(notification)
const dismiss = () => removeNotification(notification.id)
return (
<Component
key={notification.id}
notification={notification}
dismiss={dismiss}
/>
)
}
)
}
</div>
)
};
}
kind, to not confuse it with Action Types.domain's used in the
application. A domain is the part of the application where the notification
will be displayed. We currently have: global, page and sideaddNotification is a low-level function. It's recommended to use it in your
own action-creators, and use your own action-creators in your application
exclusively calling addNotification behind the scenes.removeNotification(id) on each one: state.notifications.forEach(notif => removeNotification(notif.id)). Simply resetting the state would lead to
the onDismiss callbacks not being fired.kind to decide which component to render
or which style to use.kind, pass any required information and handle it in the component rendering
the notification.FAQs
A general-purpose notification system built on top of redux
The npm package @commercetools-frontend/notifications receives a total of 5,703 weekly downloads. As such, @commercetools-frontend/notifications popularity was classified as popular.
We found that @commercetools-frontend/notifications demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.