Skip to main content

Documentation Index

Fetch the complete documentation index at: https://cometchat-22654f5b-docs-react-js-campaigns-notification-feed.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

{
  "component": "CometChatNotificationFeed",
  "package": "@cometchat/chat-uikit-react",
  "import": "import { CometChatNotificationFeed } from \"@cometchat/chat-uikit-react\";",
  "cssImport": "import \"@cometchat/chat-uikit-react/css-variables.css\";",
  "description": "Full-screen notification feed with category filtering, timestamp grouping, card rendering via @cometchat/cards-react, real-time updates, and automatic engagement reporting.",
  "cssRootClass": ".cometchat-notification-feed",
  "props": {
    "data": {
      "title": { "type": "string", "default": "\"Notifications\"" },
      "scrollToItemId": { "type": "string", "default": "undefined", "note": "Deep link to a specific feed item" },
      "notificationFeedRequestBuilder": { "type": "NotificationFeedRequestBuilder", "default": "SDK default (20 per page)" },
      "notificationCategoriesRequestBuilder": { "type": "NotificationCategoriesRequestBuilder", "default": "SDK default (50 per page)" }
    },
    "callbacks": {
      "onItemClick": "(feedItem: NotificationFeedItem) => void",
      "onActionClick": "(feedItem: NotificationFeedItem, action: CardAction) => void",
      "onError": "(error: CometChat.CometChatException) => void",
      "onBackPress": "() => void"
    },
    "visibility": {
      "showHeader": { "type": "boolean", "default": true },
      "showBackButton": { "type": "boolean", "default": false },
      "showFilterChips": { "type": "boolean", "default": true }
    },
    "viewSlots": {
      "headerView": "React.ReactNode",
      "emptyStateView": "React.ReactNode",
      "errorStateView": "React.ReactNode",
      "loadingStateView": "React.ReactNode"
    },
    "cards": {
      "cardThemeMode": { "type": "\"auto\" | \"light\" | \"dark\"", "default": "\"auto\"" },
      "cardThemeOverride": { "type": "Record<string, any>", "default": "undefined" }
    },
    "style": {
      "type": "CometChatNotificationFeedStyle",
      "properties": {
        "backgroundColor": "string",
        "width": "string",
        "height": "string",
        "headerTitleColor": "string",
        "headerTitleFont": "string",
        "chipActiveBackgroundColor": "string",
        "chipActiveTextColor": "string",
        "chipInactiveBackgroundColor": "string",
        "chipInactiveTextColor": "string",
        "chipBorderColor": "string",
        "badgeBackgroundColor": "string",
        "badgeTextColor": "string",
        "separatorColor": "string",
        "timestampTextColor": "string",
        "timestampFont": "string",
        "cardBackgroundColor": "string",
        "cardBorderColor": "string",
        "cardBorderRadius": "number",
        "cardBorderWidth": "number",
        "unreadIndicatorColor": "string"
      }
    }
  },
  "automaticBehaviors": [
    "Real-time updates via WebSocket listener",
    "Delivery reporting on fetch",
    "Read reporting on viewport visibility (IntersectionObserver)",
    "Unread count polling every 30 seconds",
    "Infinite scroll pagination",
    "Timestamp grouping (Today, Yesterday, day name, date)",
    "Category filter chips with unread badges",
    "Mark all read button",
    "Offline connectivity banner"
  ],
  "additionalExports": {
    "CometChatNotificationBadge": "Standalone unread count badge component",
    "useNotificationUnreadCount": "Hook for tracking unread count with shared polling"
  }
}
CometChatNotificationFeed displays a scrollable notification feed where each item is rendered as a card using @cometchat/cards-react. It handles fetching, pagination, category filtering, timestamp grouping, real-time updates, and read/delivered/engagement reporting automatically.

Where It Fits

CometChatNotificationFeed is a full-screen component. Drop it into a page or route. It manages its own data fetching, state, and real-time listeners — you just handle navigation callbacks.
import { CometChatNotificationFeed } from "@cometchat/chat-uikit-react";
import "@cometchat/chat-uikit-react/css-variables.css";

function NotificationsPage() {
  return (
    <CometChatNotificationFeed
      showBackButton={true}
      onBackPress={() => window.history.back()}
      onItemClick={(item) => {
        // Handle item click (e.g., open detail or deep link)
      }}
    />
  );
}

Minimal Render

import { CometChatNotificationFeed } from "@cometchat/chat-uikit-react";
import "@cometchat/chat-uikit-react/css-variables.css";

function NotificationsDemo() {
  return (
    <div style={{ width: "100%", height: "100vh" }}>
      <CometChatNotificationFeed />
    </div>
  );
}

export default NotificationsDemo;
Prerequisites: CometChat SDK initialized with CometChatUIKit.init() and a user logged in. Root CSS class: .cometchat-notification-feed

Filtering Feed Items

Control what loads using custom request builders:
import { CometChatNotificationFeed } from "@cometchat/chat-uikit-react";
import { CometChat } from "@cometchat/chat-sdk-javascript";

function UnreadNotifications() {
  return (
    <CometChatNotificationFeed
      notificationFeedRequestBuilder={
        new CometChat.NotificationFeedRequestBuilder()
          .setLimit(30)
          .setReadState("unread")
          .setCategory("promotions")
          .build()
      }
    />
  );
}

Filter Options

Builder MethodDescription
.setLimit(number)Items per page (default 20, max 100)
.setReadState(state)"read", "unread", or "all"
.setCategory(string)Filter by category label
.setChannelId(string)Filter by channel
.setTags(string[])Filter by tags
.setDateFrom(string)ISO 8601 date lower bound
.setDateTo(string)ISO 8601 date upper bound

Actions and Events

Callback Props

onItemClick

Fires when a feed item card is clicked.
<CometChatNotificationFeed
  onItemClick={(item) => {
    console.log("Item clicked:", item.getId());
  }}
/>

onActionClick

Fires when an interactive element (button, link) inside a card is clicked. The action object contains the action type, parameters, and the element ID that triggered it.
<CometChatNotificationFeed
  onActionClick={(item, action) => {
    const { type, params, elementId } = action;
    switch (type) {
      case "openUrl":
        window.open(params.url, "_blank");
        break;
      case "chatWithUser":
        // Navigate to chat with params.uid
        break;
      case "chatWithGroup":
        // Navigate to group chat with params.guid
        break;
    }
  }}
/>

onError

Fires when an internal error occurs (network failure, SDK exception).
<CometChatNotificationFeed
  onError={(error) => {
    console.error("Feed error:", error.message);
  }}
/>

onBackPress

Fires when the back button in the header is clicked.
<CometChatNotificationFeed
  showBackButton={true}
  onBackPress={() => window.history.back()}
/>

Automatic Behaviors

The component handles these automatically — no manual setup needed:
BehaviorDescription
Real-time updatesNew items appear at the top via WebSocket NotificationFeedListener
Delivery reportingItems are reported as delivered when fetched
Read reportingItems are reported as read when visible in viewport (IntersectionObserver)
Unread count pollingPolls unread count every 30 seconds to update badges
Infinite scrollFetches next page when scrolling near the bottom
Timestamp groupingGroups items as “Today”, “Yesterday”, day name, or date
Category filteringFilter chips row with per-category unread badges
Mark all readHeader button to mark all notifications as read
Offline bannerShows connectivity warning when offline

Custom View Slots

headerView

Replace the entire header:
<CometChatNotificationFeed
  headerView={
    <div style={{ padding: 16, display: "flex", alignItems: "center" }}>
      <h2 style={{ margin: 0, fontSize: 20, fontWeight: "bold" }}>My Notifications</h2>
    </div>
  }
/>

State Views

<CometChatNotificationFeed
  emptyStateView={
    <div style={{ display: "grid", placeItems: "center", height: "100%" }}>
      <p>No notifications yet</p>
    </div>
  }
  errorStateView={
    <div style={{ display: "grid", placeItems: "center", height: "100%" }}>
      <p>Something went wrong</p>
    </div>
  }
  loadingStateView={
    <div style={{ display: "grid", placeItems: "center", height: "100%" }}>
      <div className="spinner" />
    </div>
  }
/>

Styling

The component uses CSS variables from the CometChat theme system. Pass a style prop for programmatic overrides, or use CSS classes for full control.

Style Prop

import { CometChatNotificationFeed } from "@cometchat/chat-uikit-react";

function StyledNotifications() {
  return (
    <CometChatNotificationFeed
      style={{
        backgroundColor: "#F5F5F5",
        chipActiveBackgroundColor: "#6852D6",
        chipActiveTextColor: "#FFFFFF",
        chipInactiveBackgroundColor: "#FFFFFF",
        chipInactiveTextColor: "#727272",
        chipBorderColor: "#E0E0E0",
        cardBackgroundColor: "#FFFFFF",
        cardBorderColor: "#E0E0E0",
        cardBorderRadius: 8,
        unreadIndicatorColor: "#6852D6",
      }}
    />
  );
}

Style Properties

PropertyTypeDescription
backgroundColorstringRoot container background
widthstringContainer width
heightstringContainer height
headerTitleColorstringHeader title text color
headerTitleFontstringHeader title font
chipActiveBackgroundColorstringSelected filter chip background
chipActiveTextColorstringSelected filter chip text color
chipInactiveBackgroundColorstringUnselected filter chip background
chipInactiveTextColorstringUnselected filter chip text color
chipBorderColorstringInactive chip border color
badgeBackgroundColorstringBadge background color
badgeTextColorstringBadge text color
separatorColorstringSeparator between items
timestampTextColorstringTimestamp text color
timestampFontstringTimestamp font
cardBackgroundColorstringCard container background
cardBorderColorstringCard border color
cardBorderRadiusnumberCard corner radius
cardBorderWidthnumberCard border width
unreadIndicatorColorstringUnread dot color

CSS Classes

Override styles using these CSS classes:
ClassDescription
.cometchat-notification-feedRoot container
.cometchat-notification-feed__headerHeader bar
.cometchat-notification-feed__header-titleHeader title text
.cometchat-notification-feed__header-backBack button
.cometchat-notification-feed__mark-all-readMark all read button
.cometchat-notification-feed__chipsFilter chips container
.cometchat-notification-feed__chipIndividual filter chip
.cometchat-notification-feed__chip--activeActive filter chip
.cometchat-notification-feed__chip--inactiveInactive filter chip
.cometchat-notification-feed__chip--inactive-with-badgeInactive chip with unread badge
.cometchat-notification-feed__chip-badgeChip unread badge
.cometchat-notification-feed__chip-badge--activeActive chip badge
.cometchat-notification-feed__chip-badge--inactiveInactive chip badge
.cometchat-notification-feed__contentScrollable content area
.cometchat-notification-feed__itemFeed item container
.cometchat-notification-feed__item--unreadUnread feed item
.cometchat-notification-feed__unread-indicatorUnread dot indicator
.cometchat-notification-feed__item-metaItem metadata row (category + time)
.cometchat-notification-feed__item-categoryCategory label
.cometchat-notification-feed__item-timeTimestamp
.cometchat-notification-feed__card-containerCard wrapper
.cometchat-notification-feed__loadingLoading state
.cometchat-notification-feed__emptyEmpty state
.cometchat-notification-feed__errorError state
.cometchat-notification-feed__connectivity-bannerOffline banner

Props

All props are optional.

cardThemeMode

Theme mode for the card renderer (@cometchat/cards-react).
Type"auto" | "light" | "dark"
Default"auto"

cardThemeOverride

Custom theme override passed to the card renderer.
TypeRecord<string, any>
Defaultundefined

emptyStateView

Custom component displayed when there are no notifications.
TypeReact.ReactNode
DefaultBuilt-in empty state with illustration

errorStateView

Custom component displayed when an error occurs.
TypeReact.ReactNode
DefaultBuilt-in error state with retry button

headerView

Custom component replacing the entire header.
TypeReact.ReactNode
DefaultBuilt-in header with title and mark-all-read button

loadingStateView

Custom component displayed during the initial loading state.
TypeReact.ReactNode
DefaultBuilt-in loading spinner

notificationCategoriesRequestBuilder

Custom request builder for fetching categories.
TypeCometChat.NotificationCategoriesRequestBuilder
DefaultSDK default (50 per page)

notificationFeedRequestBuilder

Custom request builder for fetching feed items.
TypeCometChat.NotificationFeedRequestBuilder
DefaultSDK default (20 per page)

onActionClick

Callback fired when an interactive element inside a card is clicked.
Type(feedItem: NotificationFeedItem, action: CardAction) => void
Defaultundefined
The CardAction object contains:
  • type — Action type (e.g., "openUrl", "chatWithUser")
  • params — Action parameters (e.g., { url: "..." }, { uid: "..." })
  • elementId — ID of the element that triggered the action

onBackPress

Callback fired when the back button is pressed.
Type() => void
Defaultundefined

onError

Callback fired when the component encounters an error.
Type(error: CometChat.CometChatException) => void
Defaultundefined

onItemClick

Callback fired when a feed item card is clicked.
Type(feedItem: NotificationFeedItem) => void
Defaultundefined

scrollToItemId

Deep link to a specific feed item by ID. The component scrolls to the item once loaded.
Typestring
Defaultundefined

showBackButton

Shows/hides the back button in the header.
Typeboolean
Defaultfalse

showFilterChips

Shows/hides the category filter chips row.
Typeboolean
Defaulttrue

showHeader

Shows/hides the entire header.
Typeboolean
Defaulttrue

style

Style customization object.
TypeCometChatNotificationFeedStyle
Defaultundefined

title

Header title text.
Typestring
Default"Notifications"

Additional Exports

CometChatNotificationBadge

A standalone badge component that displays the unread notification count. Uses a shared polling singleton — multiple badges share one interval and listener.
import { CometChatNotificationBadge } from "@cometchat/chat-uikit-react";

function NavBar() {
  return (
    <nav>
      <a href="/notifications">
        Notifications <CometChatNotificationBadge />
      </a>
    </nav>
  );
}

Props

PropTypeDefaultDescription
categorystringundefinedFilter count by category
maxnumber99Maximum count before showing “N+“
style.backgroundColorstring"#6852D6"Badge background color
style.textColorstring"#fff"Badge text color
style.fontSizestring"11px"Badge font size
style.borderRadiusstring"9999px"Badge border radius

useNotificationUnreadCount

A React hook for tracking unread notification count. Uses a shared singleton — multiple components share one polling interval and WebSocket listener.
import { useNotificationUnreadCount } from "@cometchat/chat-uikit-react";

function NotificationIcon() {
  const { count, refresh, isLoading } = useNotificationUnreadCount();

  return (
    <button onClick={refresh}>
      🔔 {count > 0 && <span className="badge">{count}</span>}
    </button>
  );
}

Return Value

FieldTypeDescription
countnumberCurrent unread count
refresh() => Promise<void>Manually refresh the count
isLoadingbooleanWhether the initial fetch is in progress

Options

OptionTypeDefaultDescription
categorystringundefinedFilter count by category
pollingIntervalnumber30000Polling interval in milliseconds

Common Patterns

Show only unread items

<CometChatNotificationFeed
  notificationFeedRequestBuilder={
    new CometChat.NotificationFeedRequestBuilder()
      .setReadState("unread")
      .build()
  }
/>

Hide filter chips and header

<CometChatNotificationFeed
  showHeader={false}
  showFilterChips={false}
/>
<CometChatNotificationFeed
  scrollToItemId="notification-item-id-123"
/>

Embed in a sidebar

import { CometChatNotificationFeed } from "@cometchat/chat-uikit-react";
import "@cometchat/chat-uikit-react/css-variables.css";

function NotificationsSidebar() {
  return (
    <div style={{ width: 400, height: "100vh", borderLeft: "1px solid #E0E0E0" }}>
      <CometChatNotificationFeed
        title="Updates"
        showBackButton={false}
      />
    </div>
  );
}

Add notification badge to navigation

import {
  CometChatNotificationFeed,
  CometChatNotificationBadge,
} from "@cometchat/chat-uikit-react";
import "@cometchat/chat-uikit-react/css-variables.css";

function App() {
  const [showFeed, setShowFeed] = useState(false);

  return (
    <>
      <nav>
        <button onClick={() => setShowFeed(!showFeed)}>
          🔔 <CometChatNotificationBadge max={99} />
        </button>
      </nav>
      {showFeed && (
        <CometChatNotificationFeed
          onBackPress={() => setShowFeed(false)}
          showBackButton={true}
        />
      )}
    </>
  );
}

Next Steps

Campaigns Feature

Overview of how campaigns work end-to-end

SDK Campaigns API

Low-level SDK APIs for feed items, categories, and engagement

Theming

Customize colors, fonts, and appearance

Components

Browse all prebuilt UI components