I'm currently facing an issue while trying to integrate Firebase (Firestore) into my Nuxt project. When I try to initialize a const using firebase.firestore()
in my index.vue
file, I encounter the following error:
Uncaught FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).
I have successfully installed Firebase and the necessary module (@nuxtjs/firebase
) in my project.
Here is how my nuxt.config.js file is configured:
export default {
...
plugins: ['~/plugins/firebase.js'],
components: true,
buildModules: [
'@nuxt/typescript-build',
'@nuxtjs/tailwindcss',
],
modules: [],
...
}
My firebase.js file can be found within the plugins folder and it looks like this:
import firebase from 'firebase/app'
const config = {
...
}
let app = null
if (!firebase.apps.length) {
app = firebase.initializeApp(config)
}
export default firebase
I've compared my setup with other examples online but haven't been able to identify any issues. As someone new to both Nuxt and Firebase, I may be overlooking something obvious. Any suggestions would be greatly appreciated.