The useNovu hook is used to obtain the Novu instance, which allows you to interact with the headless SDK interface.

The hook returns the Novu class instance with multiple methods to interact with the Novu API.

Example usage

The below example demonstrates how to use the useNovu hook to listen for new notifications and show a toast notification.

import { useNovu } from '@novu/react-native';

const NotificationToast = () => {
  const novu = useNovu();

  useEffect(() => {
    const listener = ({ result: notification }) => {
      // Show a toast notification
    };

    novu.on('notifications.notification_received', listener);

    return () => {
      novu.off('notifications.notification_received', listener);
    };
  }, [novu]);

  return null;
};