Overview
Notifications should arrive instantly without page refresh. This issue connects the frontend to the WebSocket notifications gateway (BE-55) using socket.io-client and pushes received events into the notification bell (FE-27) and as toast alerts.
Context
socket.io-client@4.8.3 is already installed in frontend/package.json
- The existing
frontend/hooks/useWebSocket.ts file provides a base — extend it for notifications
- Backend WebSocket namespace:
/notifications (from BE-55)
- Authentication: pass
{ auth: { token: accessToken } } in the socket connection options
Acceptance Criteria
Overview
Notifications should arrive instantly without page refresh. This issue connects the frontend to the WebSocket notifications gateway (BE-55) using
socket.io-clientand pushes received events into the notification bell (FE-27) and as toast alerts.Context
socket.io-client@4.8.3is already installed infrontend/package.jsonfrontend/hooks/useWebSocket.tsfile provides a base — extend it for notifications/notifications(from BE-55){ auth: { token: accessToken } }in the socket connection optionsAcceptance Criteria
frontend/hooks/useNotificationSocket.ts— connects toNEXT_PUBLIC_API_URLon the/notificationsnamespace, passing the JWT from auth store asauth.tokennotificationevent: add the notification to the React QueryuseNotificationscache and increment the unread count badgelogout()action)useNotificationSocket()from the dashboard layout (frontend/app/(dashboard)/layout.tsx) so it runs for all authenticated pages