0.1.0 • Published 6 years ago

vue-firebase-plugin v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

VueFirebase - Firebase Plugin for Vue.js

Installation

$ npm i -D vue-firebase-plugin

or if using Yarn:

$ yarn add -D vue-firebase-plugin

How to use

import Vue from 'vue'
import VueFirebase from 'vue-firebase-plugin'
Vue.use(VueFirebase)

new Vue({
  firebase: {
    '[DEFAULT]': {
      apiKey: "<API_KEY>",
      authDomain: "<PROJECT_ID>.firebaseapp.com",
      databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
      storageBucket: "<BUCKET>.appspot.com",
      messagingSenderId: "<SENDER_ID>",
    }
  }
})
export default {
  template: '<div>{{uid}}</div>',
  computed: {
    uid() {
      return this.$firebase().$auth.user.uid
    }
  }
}
import {mapBind} from 'vue-firebase-plugin'
export default {
  template: '<div>{{foo}}</div>',
  computed: {
    ...mapBind({
      foo: store => store.doc('foo/doc'),
    }),
    // or manually
    foo() {
      return this.$firebase().$store.query(
        store => store.doc('foo/doc')
      ).bind() // need bind
    },

    // using component data
    ...mapBind({
      userdoc: (store, vm) =>
        store.doc(`${vm.uid}/doc`),
    }),
  }
})

Support Status

FirebaseStatus
AuthSupported
FireStoreSupported
Realtime DatabaseNOT Supported
StorageWIP

Optional Plugin

PluginStatusDescription
VuexWIPBinding Firebase data to vuex Store
Vue RouterWIPGuard Firebase Auth informations for vue-router

Create plugin

Plugin object need has install function.