import { NotificationFilter, Notification, NovuError } from '@novu/js';
/**
* Props for the useNotifications hook.
*
* @example
* ```tsx
* // Get unread notifications
* const { notifications } = useNotifications({
* read: false
* });
*
* // Get unseen notifications with specific tags
* const { notifications } = useNotifications({
* seen: false,
* tags: ['important']
* });
*
* // Get notifications (auto-updates in real time when new notifications arrive)
* const { notifications } = useNotifications({
* read: false
* });
*
* // Get notifications from a specific time period
* const { notifications } = useNotifications({
* createdGte: 1704067200000,
* createdLte: 1735689599999
* });
*
* // Opt out of the built-in realtime updates and drive them yourself
* const { notifications, refetch } = useNotifications({
* read: false,
* realtime: false,
* });
* ```
*/
type UseNotificationsProps = {
tags?: NotificationFilter['tags'];
data?: NotificationFilter['data'];
read?: NotificationFilter['read'];
archived?: NotificationFilter['archived'];
snoozed?: NotificationFilter['snoozed'];
seen?: NotificationFilter['seen'];
severity?: NotificationFilter['severity'];
createdGte?: NotificationFilter['createdGte'];
createdLte?: NotificationFilter['createdLte'];
limit?: number;
/**
* When `false`, disables the WebSocket subscription that auto-injects
* newly received notifications into the list. Built-in mutations like
* `readAll`, `seenAll`, `archiveAll`, and `archiveAllRead` continue to
* update local state. Use this when you want to drive new-notification updates yourself (e.g.
* via your own `novu.on('notifications.notification_received', ...)`
* handler combined with `refetch()`).
*
* When set, this prop takes precedence over the `realtime` config on
* ``. When omitted, the provider value (default `true`) is used.
*/
realtime?: boolean;
onSuccess?: (data: Notification[]) => void;
onError?: (error: NovuError) => void;
};
type UseNotificationsResult = {
notifications?: Notification[];
error?: NovuError;
isLoading: boolean;
isFetching: boolean;
hasMore: boolean;
readAll: () => Promise<{
data?: void | undefined;
error?: NovuError | undefined;
}>;
seenAll: () => Promise<{
data?: void | undefined;
error?: NovuError | undefined;
}>;
archiveAll: () => Promise<{
data?: void | undefined;
error?: NovuError | undefined;
}>;
archiveAllRead: () => Promise<{
data?: void | undefined;
error?: NovuError | undefined;
}>;
refetch: () => Promise;
fetchMore: () => Promise;
};
declare const useNotifications: (props?: UseNotificationsProps) => UseNotificationsResult;
export { useNotifications };
export type { UseNotificationsProps, UseNotificationsResult };