Live Notifications Not Working in Bolt App
Your Bolt.new application has a notification system that stores notifications in the database, but users only see them after refreshing the page. The notification bell or badge doesn't update in real-time, so users miss time-sensitive alerts like new orders, messages, or system warnings.
Live notifications are essential for any interactive application. When a user receives a new message, a buyer places an order, or a system event requires attention, the user needs to know immediately without manually checking. A notification system that requires page refreshes defeats its entire purpose.
Bolt typically generates the notification storage and display components but misses the real-time delivery mechanism. The notifications exist in the database but the frontend has no way to know about new ones until it re-fetches the list.
Error Messages You Might See
Common Causes
- Polling not implemented — No mechanism to periodically check for new notifications or receive them in real-time
- Supabase Realtime subscription missing — Notifications are stored in a table but there's no subscription listening for new inserts
- Notification count not updating — The badge shows the count from initial page load and never recalculates when new notifications arrive
- Global state not connected — The notification listener runs in one component but the badge count is managed in a separate component without shared state
- User filter not applied — The Realtime subscription listens for all notifications instead of filtering for the current user's notifications
How to Fix It
- Create a notification provider — Build a React context that wraps your app and manages notification state globally, so all components can access the notification count and list
- Subscribe to user-specific notifications — Add a Realtime subscription filtered to the current user: supabase.channel('notifications').on('postgres_changes', { event: 'INSERT', schema: 'public', table: 'notifications', filter: `user_id=eq.${userId}` }, handleNewNotification).subscribe()
- Update badge count reactively — When a new notification arrives, increment the unread count: setUnreadCount(prev => prev + 1) and add the notification to the list
- Show toast for important notifications — Display a temporary toast notification for high-priority items using a library like react-hot-toast or sonner
- Mark as read on view — When the user opens the notification panel, mark visible notifications as read: await supabase.from('notifications').update({ read: true }).eq('user_id', userId).eq('read', false)
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
Should I use polling or WebSocket for notifications?
Use Supabase Realtime (WebSocket) for instant delivery. Polling every few seconds creates unnecessary load and still has delays. Supabase Realtime pushes new rows to the client within milliseconds of database insertion.
How do I handle notifications when the user is offline?
Store all notifications in the database with a 'read' boolean field. When the user reconnects, fetch all unread notifications: supabase.from('notifications').select().eq('user_id', userId).eq('read', false). The Realtime subscription only handles new notifications while connected.