Issue
I use Firebase on a lot of my projects, but I never used it with vue 3 before. For an Ionic Project, I am using Vue 3 with typescript. What I would do to initialize Firebase projects on Vue 2 is, on the main.js file, this:
new Vue({
router,
created() {
firebase.initializeApp(firebaseConfig)
}}).$mount('#app')
On vue 3 - main.ts -, tried:
const app = createApp(App, {
created(){
firebase.initializeApp(firebaseConfig)
}
})
But I get the message:
Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp()
It works if the initializeApp()
is outside "app definition", in the root of the file. What could be the problem? Thanks
Solution
You need to initiate Firebase at the start of your app before even Vue is created, ideally in a dedicated firebase.js script that manages Firebase within your app.
firebase.initializeApp(firebaseConfig)
new Vue({
router
}).$mount('#app')
Answered By - DIGI Byte
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.