'Messaging: This browser doesn't support the API's required to use the Firebase SDK

Im building a web chat app with next.js and im trying to implement push notifications with firebase but im getting stuck on this error:

error - unhandledRejection: FirebaseError: Messaging: This browser doesn't support the API's required to use the Firebase SDK. (messaging/unsupported-browser)

error - Error: Service messaging is not available.

import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';
import { getStorage } from "firebase/storage";
import { getMessaging } from "firebase/messaging";


const firebaseConfig = {
 ...
}; 

const app = !firebase.apps.length
? firebase.initializeApp(firebaseConfig)
: firebase.app();

const messaging=getMessaging(app)
const db =app.firestore();
const auth=app.auth();
const provider=new firebase.auth.GoogleAuthProvider();
export const storage = getStorage(app);
export{db,auth,provider};

What can i do to solve this problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source