Reactjs Push Notifications
A solution for pushing browser web notification! reactjs-push-notification
is an npm package that allows you to push notifications to the browser. It can be used with both Next.js and React.js. The package is easy to use and provides a variety of customization options.
Features
- It is open source and licensed under the MIT license.
- It is compatible with React.js 16.8+ and Next.js 9.5+.
- It has been tested in Chrome, Firefox, and Safari.
- It is well-documented and includes examples.
Installing
$ npm install reactjs-push-notification
Example
import { pushNotification, NotificationPrompt } from "reactjs-push-notification";
const Push = () => {
const buttonClick = () => {
pushNotification({
title: "Warning",
subtitle: "This is a subtitle!",
message: "This is a long message!"
});
};
return (
<div className="page">
<NotificationPrompt />
<button onClick={buttonClick} className="button">
Push Notifications
</button>
</div>
);
};
export default Push;
Options
Name | Is Required | Default |
---|---|---|
title | Required (String) | Notification Title |
subtitle | Optional (String) | Notification Subtitle |
message | Optional (String) | Notification Message Body |
onClick | Optional (Function) | |
duration | Optional (Number) | Notification Duration Time |
Stay in touch
- Author - Siam Ahnaf
- Website - https://www.siamahnaf.com/
- Twitter - https://twitter.com/siamahnaf198
- Github - https://github.com/siamahnaf