# Firebase: No Firebase App '\[DEFAULT\]' has been created in React app

**URL:** <https://forum.ionicframework.com/t/firebase-no-firebase-app-default-has-been-created-in-react-app/233856>\
**Category:** Ionic Framework\
**Created:** [June 1, 2023, 9:50am UTC](https://forum.ionicframework.com/t/firebase-no-firebase-app-default-has-been-created-in-react-app/233856 "2023-06-01T09:50:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flyon](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/flyon/32/144430_2.png) [@flyon](https://forum.ionicframework.com/u/flyon)\
**Post date:** [June 1, 2023, 9:50am UTC](https://forum.ionicframework.com/t/firebase-no-firebase-app-default-has-been-created-in-react-app/233856/1 "2023-06-01T09:50:18Z")

</div>

Hey guys, I’m trying to set up push notifications, starting with web. I’m following this guide

> **[Push Notifications Capacitor Plugin API | Capacitor Documentation](https://capacitorjs.com/docs/apis/push-notifications)**
>
> The Push Notifications API provides access to native push notifications.

and this guide

> **[The Push Notifications Guide for Capacitor - Capawesome](https://capawesome.io/blog/the-push-notifications-guide-for-capacitor/)**
>
> Capawesome offers enterprise-grade solutions and services designed for teams building cross-platform apps with Capacitor.

I’ve setup firebase and followed all the steps, but I’m not getting past this point:  
When requesting a token from firebase

```auto
const {token} = await FirebaseMessaging.getToken(options);

```

I’m getting this error:

```auto
FirebaseError
Firebase: No Firebase App '[DEFAULT]' has been created - call initializeApp() first (app/no-app).

```

I’ve installed the following package.json:

```auto
    "@capacitor-firebase/messaging": "^5.0.0",
    "@capacitor/core": "^5.0.3",
    "firebase": "^9.22.1",

```

The errors say call initializeApp first. But I’m definitly calling initializeApp() first… Perhaps not in the right way or place? The guide is for angular, so I’m trying to make it work for React. Below is a simplified setup without any components. Just calling initialize and then trying to get a token.

```auto
import {Capacitor} from '@capacitor/core';
import {initializeApp} from 'firebase/app';
import {FirebaseMessaging,GetTokenOptions} from '@capacitor-firebase/messaging';

export async function requestPermissions() {
  await FirebaseMessaging.requestPermissions();
}

export async function getTokenFirebase() {
  const options: GetTokenOptions = {
    vapidKey: '',
  };
  if (Capacitor.getPlatform() === 'web') {
    console.log('web');
    options.serviceWorkerRegistration = await navigator.serviceWorker.register('firebase-messaging-sw.js');
  }
  const {token} = await FirebaseMessaging.getToken(options);

  console.log('getToken', token);
  return token;
}

const initializeFirebase = () => {
  if (Capacitor.isNativePlatform()) {
    return;
  }
  return initializeApp({
    apiKey: '',
    authDomain: '',
    projectId: '',
    storageBucket: '',
    messagingSenderId: '',
    appId: '',
    measurementId: '',
  });
};
//initialize firebase right at the start when the app starts up
let app = initializeFirebase();
console.log('Firebase initialized',app);
getTokenFirebase().then((token) => {
  console.log(token);
})

```

The logs show that firebase is initialised with an app

 ![image](https://global.discourse-cdn.com/ionicframework/original/3X/f/5/f58ed9a29b56bd2e504148e8607d4e581528b11b.png)

If anyone has a better guide that I can follow / example setup / knows how to get past this error, help is much appreciated as I’ve been stuck on this for a while now.
