Firebase Push Notifications Failing in Bolt App
Your Bolt.new application is set up with Firebase Cloud Messaging (FCM) for push notifications, but users never receive them. The notification permission prompt may not appear, tokens fail to generate, or notifications are sent from the backend but never arrive on users' devices.
Push notifications are essential for user re-engagement: notifying users about new messages, order updates, price alerts, or time-sensitive events. When they don't work, your app loses its ability to bring users back, and you have to rely entirely on email which has much lower engagement rates.
Firebase push notifications involve multiple moving parts: a service worker on the client, a valid FCM token per device, proper Firebase configuration, and a server-side component that sends the actual notifications. Bolt's AI typically sets up some of these pieces but misses critical configuration steps.
Error Messages You Might See
Common Causes
- Service worker not registered — Firebase requires a firebase-messaging-sw.js service worker file in the public root directory, which Bolt may not have created
- Firebase config mismatch — The Firebase configuration in the app doesn't match the project in Firebase Console, so FCM can't authenticate
- Notification permission not requested — The app never calls Notification.requestPermission(), so the browser blocks all notifications
- FCM token not saved — The device token is generated but never sent to your backend for storage, so you can't target the user for notifications
- VAPID key missing — The Voluntary Application Server Identification (VAPID) key is not configured, which is required for web push
- Browser or OS blocking notifications — The user or their OS has disabled notifications globally, and your app doesn't detect or communicate this
How to Fix It
- Create the service worker file — Add firebase-messaging-sw.js to your public folder: importScripts('https://www.gstatic.com/firebasejs/10.7.0/firebase-app-compat.js', 'https://www.gstatic.com/firebasejs/10.7.0/firebase-messaging-compat.js'); firebase.initializeApp({...config}); firebase.messaging();
- Request permission properly — Ask for notification permission with context: show a UI explaining why notifications are useful before calling Notification.requestPermission()
- Generate and save FCM token — After permission is granted: const token = await getToken(messaging, { vapidKey: process.env.NEXT_PUBLIC_FIREBASE_VAPID_KEY }); await saveTokenToBackend(token, userId);
- Configure VAPID key — In Firebase Console > Project Settings > Cloud Messaging, generate a Web Push certificate key pair and use the public key as your VAPID key
- Send from backend with Admin SDK — Use Firebase Admin SDK on the server: admin.messaging().send({ token: userFcmToken, notification: { title: 'New message', body: 'You have a new message' } })
- Handle token refresh — FCM tokens expire and refresh. Listen for token changes: onMessage(messaging, (payload) => handleForegroundMessage(payload))
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
Do Firebase push notifications work on iOS Safari?
Yes, but only since iOS 16.4 and only for apps added to the Home Screen (PWA). Standard Safari doesn't support Web Push. For full iOS support, you need a native app wrapper or use a service like OneSignal that handles the complexity.
Why do notifications work in development but not in production?
Common causes: the firebase-messaging-sw.js file isn't in the production build output, the VAPID key is different between environments, or the Firebase project used in development differs from production. Verify all Firebase config values match your production Firebase project.