Design a Frontend Notification System
System design for toasts, badges, and notification center: queue management, auto-dismiss, priority, read/unread, real-time delivery (SSE/WebSocket), filtering, push notifications, and overflow behavior.
Designing a frontend notification system tests queue management, real-time data, accessibility, and cross-cutting UI concerns. Here's a structured approach.
Requirements Clarification
Functional Requirements
- Toasts: Temporary messages (success, error, info, warning); auto-dismiss; manual dismiss; stack when multiple.
- Badge: Unread count on nav icon (e.g., bell); updates in real time.
- Notification Center: Full list of notifications; filter by read/unread, category; mark as read; pagination.
- Real-time: New notifications arrive via SSE or WebSocket without polling.
- Push: Optional browser push notifications when tab is backgrounded.
Non-Functional Requirements
- Max N toasts visible (e.g., 3–5); queue overflow behavior (drop oldest, or show "+N more").
- Screen reader announcements for important toasts (live region).
- Performant with hundreds of notifications in the center.
High-Level Architecture
┌─────────────────────────────────────────────────────────────┐
│ NotificationProvider (Context) │
├─────────────────────────────────────────────────────────────┤
│ ToastQueue │ NotificationCenter (state) │
│ - active toasts │ - notifications[] │
│ - maxVisible: 5 │ - unreadCount │
│ - priority queue │ - filters, pagination │
├─────────────────────┴───────────────────────────────────────┤
│ RealTimeConnection (SSE/WebSocket) │ useToast(), useNotifications() │
└─────────────────────────────────────────────────────────────┘
Continue reading Design a Frontend Notification System
Sign in or create a free account to read the rest of this article and all premium content.
Sign in to continue readingRelated articles
- System DesignDesign a Comments Thread
System design for nested comments: replies, pagination, real-time updates, and moderation. Frontend architecture and data shape.
Read article - System DesignDesign a Real-Time Chat Application
System design for Slack/WhatsApp-style chat: WebSocket management, message ordering, offline support, typing indicators, read receipts, search, and file uploads.
Read article - System DesignDesign a Search Results Page
System design for a search results page: filters, sorting, facets, infinite scroll vs pagination, and performance at scale.
Read article - System DesignDesign Autocomplete / Typeahead Search
System design for building a Google-like autocomplete search component: debouncing, caching, keyboard navigation, race conditions, and mobile considerations.
Read article