Has anyone used Vue with Firebase here? What's the best way to pass the Firebase object around components?
For further actions, you may consider blocking this person and/or reporting abuse
Has anyone used Vue with Firebase here? What's the best way to pass the Firebase object around components?
For further actions, you may consider blocking this person and/or reporting abuse
Jahid Hasan -
Saulo Dias -
Mudunuri bhaskara karthikeya varma -
Wanda -
Top comments (4)
I always have my firebase db actions handled in the vuex store! That way, you never have to directly manipulate the firebase object inside a component, instead you can just call
this.$store.commit('updateXProperty', value)
to send your mutations to a centralized source. It makes debugging easier, and database updates safer since you can add your own data validation in the store that'll be applied to all updates throughout your app.In fact, I often split all firebase actions out into their own file that I simply import once in the vuex store, just to further separate different tasks.
Thanks for the tip, Jasper! I asked on the Vue Discord as well and they said I should check VueFire.
Another question, though. How about the authentication? Do you use Vuex for it as well?
I'd definitely rely on the vue discord's advice, as they're much more the authority than I am :)
I usually use dotenv for my credentials, which is just imported in my database handling file, which handles credentials for my database.
You should read this post => Vue 2 + Firebase: How to build a Vue app with Firebase authentication system in 15 minutes