firebase / firebase/firebase-js-sdk

Service messaging is not available

Open
#7,707 9 comments 0 reactions 0 assignees View on GitHub
api: messaging needs-attention question stack:NextJS
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

Description

### Operating System

Windows 10

### Browser Version

Chrome v118.0.5993.88

### Firebase SDK Version

9.9.4

### Firebase SDK Product:

Messaging

### Describe your project's tooling

I have a NextJS app (v12)

### Describe the problem

The problem is when i try to configure the firebase file, the following error is occuring:

Error: Service messaging is not available

![image](https://github.com/firebase/firebase-js-sdk/assets/56257079/2628bfb5-d80e-4ef4-9f92-c5e48de370f0)

I also have this error:
![image](https://github.com/firebase/firebase-js-sdk/assets/56257079/e9efe4a7-6300-4c0c-af9b-a6d3b565d60c)

### Steps and code to reproduce issue

`Firebase.ts:`

```
import { initializeApp } from "firebase/app";
import { getMessaging, getToken } from "firebase/messaging";

const firebaseConfig = {
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGE_SENDER_ID,
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
};

const app = initializeApp(firebaseConfig);

const messaging = getMessaging(app);
```

PS: I've seen some threads that recommend downgrading firebase to v8, but I'd like to keep it in v9. Is there any way to fix this?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.