Overview
The@sirenapp/react-inbox
SDK is a comprehensive and customizable React UI kit for displaying and managing notifications. This documentation provides comprehensive information on how to install, configure, and use the SDK effectively.
Installation
Prerequisites
- React v16.8+
Configuration
Initialization
Initialize the SDK with user token and recipient ID. Wrap the provider around your App’s root.Configure Notification Inbox
Once the provider is configured, the next step is to set up the notification inbox. TheSirenInbox
component provides a paginated list view for displaying notifications.
Props for the Notification Inbox
Prop | Description | Type | Default Value |
---|---|---|---|
theme | Object for custom themes | Theme | {} |
customStyles | Object for custom styling | CustomStyle | {} |
loadMoreLabel | Text shown on the load more component | string | "Load More" |
hideBadge | Toggle to hide or show the badge | boolean | false |
darkMode | Toggle to enable dark mode | boolean | false |
hideTab | Toggle to enable all and unread tabs | boolean | false |
tabProps | Props for customizing tabs | TabProps | See below |
itemsPerFetch | Number of notifications per API request (max 50) | number | 20 |
windowViewOnly | Toggle for fit-to-screen window or modal view | boolean | false |
notificationIcon | Custom notification icon | JSX.Element | null |
headerProps | Props for customizing the header | HeaderProps | See below |
cardProps | Props for customizing notification cards | CardProps | See below |
customCard | Function for rendering custom notification cards | (notification) => JSX.Element | null |
onCardClick | Custom click handler for notification cards | (notification) => void | () => null |
listEmptyComponent | Custom component for empty notification list | JSX.Element | null |
customFooter | Custom footer component | JSX.Element | null |
customLoader | Custom loader component | JSX.Element | null |
loadMoreComponent | Custom load more component | JSX.Element | null |
customErrorWindow | Custom error window component | JSX.Element | null |
onError | Error callback function | (error: SirenErrorType) => void | null |
Customization
Customize the appearance of the notification inbox using themes:Theme Customization
Style Customization
Component Props
CardProps
InboxHeaderProps
Hooks
useSiren
TheuseSiren
hook provides utility functions for modifying notifications:
useSiren Functions
Function | Parameters | Type | Description |
---|---|---|---|
markAsReadByDate | { startDate: string, isRead?: boolean } | object | Updates read status of notifications up to the specified date |
markAsReadById | id: string | string | Sets read status of a notification to true |
deleteById | id: string | string | Deletes a notification by ID |
deleteByDate | { startDate: string, isRead?: boolean } | object | Deletes notifications until the given date |
markAllAsViewed | untilDate: string | string | Sets the viewed status of notifications to true until the given date |