Skip to content
pubscout

firebase_messaging_web

4.4.0, released 4 days ago by firebase.google.com

Web implementation of Firebase Cloud Messaging for push notifications.

WASM-ready
$ flutter pub add firebase_messaging_web
Source repository

What it does

Provides the web side of Firebase Messaging, allowing Flutter web apps to receive push notifications via Firebase Cloud Messaging. It registers service workers and handles token management and message callbacks.

AI-written summary of version 4.3.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need push notifications in a Flutter web app using Firebase
  • You already use other Firebase services like firebase_core
  • You want a simple integration without custom native code

Skip it when

  • You target only mobile platforms
  • You need a non‑Firebase push solution

Strengths

  • Official Firebase support
  • Works seamlessly with other FlutterFire packages
  • Handles service‑worker registration and token retrieval

Weaknesses

  • Web‑only; no mobile support
  • Limited to Firebase ecosystem

Setup

Kind
Plugin (native code)
Effort
Low
Code generation
No
Direct dependencies
6

Add firebase_core and firebase_core_web, configure Firebase project, ensure a service worker file is present as described in Firebase docs

import 'package:firebase_messaging_web/firebase_messaging_web.dart';

void main() async {
  FirebaseMessaging messaging = FirebaseMessaging.instance;
  String? token = await messaging.getToken();
  print('FCM token: $token');
  FirebaseMessaging.onMessage.listen((RemoteMessage message) {
    print('Received message: ${message.notification?.title}');
  });
}

Alternatives

Packages that do the same job and could replace firebase_messaging_web.

Works with

Packages commonly used together with firebase_messaging_web: ones it builds on, ones built on it, and its own family.