Overview
TheNotifications component provides a notification center for collaborative features. It displays unread notifications including mentions, thread replies, and custom document access notifications. Built with Liveblocks inbox system and Shadcn Popover.
Props
This component takes no props. It uses Liveblocks hooks to automatically fetch notifications for the current user.Features
- Real-time Notifications: Powered by Liveblocks inbox
- Unread Count Badge: Visual indicator for new notifications
- Multiple Notification Types:
- Thread notifications
- Text mentions (@mentions)
- Custom document access notifications
- Deep Links: Click notifications to navigate to relevant document
- Auto-sync: Notifications update in real-time
- Custom UI: Styled notification components
Usage Example
Basic Usage
With Liveblocks Provider
Component Structure
Liveblocks Hooks
The component uses two Liveblocks hooks:useInboxNotifications
useUnreadInboxNotificationsCount
Notification Types
The component handles three notification kinds:1. Thread Notifications
2. Text Mentions
3. Document Access (Custom)
UI Customization
Notification Badge
Empty State
Custom Text Overrides
Notification Filtering
Only unread notifications are displayed:Navigation
Each notification includes a deep link:Styling
Popover Trigger
Popover Content
Notification Item
Notification Properties
| Property | Description |
|---|---|
showActions | Hide action buttons (set to false) |
showRoomName | Hide room name in notification |
href | Navigation URL on click |
className | Custom styling classes |
TypeScript Types
Dependencies
- @liveblocks/react-ui: UI components for notifications
- @liveblocks/react/suspense: Hooks for inbox data
- Shadcn UI: Popover component
- Next.js Image: Optimized avatar images
Common Use Cases
In App Header
With Other Collaboration Features
Best Practices
- Wrap in LiveblocksProvider: Ensure the component is within Liveblocks context
- Position Appropriately: Typically in app header or navigation
- Accessibility: Bell icon includes proper alt text
- Mobile Responsive: Popover aligns appropriately on all screens
Related Components
- CollaborativeRoom - Uses notifications for collaboration
- Comments - Generates thread and mention notifications
- ActiveCollaborators - Often displayed alongside notifications