@21kb/react-notification-hook

React hook to use the Notifications API

Usage no npm install needed!

<script type="module">
  import 21kbReactNotificationHook from 'https://cdn.skypack.dev/@21kb/react-notification-hook';
</script>

README

@21kb/react-notification-hook

React hook to use the Notifications API

Install

npm

npm install --save @21kb/react-notification-hook

Yarn

yarn add @21kb/react-notification-hook

Usage

import useNotification from '@21kb/react-notification-hook';

const Component = () => {
  const notify = useNotification({
    title: '💡 Test notification!',
    options: {
      dir: 'rtl',
    }
  });

  return (
    <button onClick={notify()}>Notify me!</button>
  );
};

NOTE: useNotification assumes the user has already granted permissions.

License

MIT