Skip to content

Latest commit

 

History

History
35 lines (31 loc) · 1.01 KB

8. Firebase with Vue.md

File metadata and controls

35 lines (31 loc) · 1.01 KB

Firebase with Vue.js

  1. Create vue.js app with vue create your_vue_app_name
  2. Install Firebase npm module npm install --save firebase
  3. create config/firebase.js file in src dir
  4. Write the following code
  import firebase from "firebase/app";
  import "firebase/auth";
  import "firebase/firestore";
  import "firebase/performance";
  import "firebase/messaging";

  const firebaseConfig = {
    // Firebase Config File
  };

  firebase.initializeApp(firebaseConfig);
  firebase
    .firestore()
    .enablePersistence({ synchronizeTabs: !0 })
    .catch(() => {
      console.warn("DB offline support not available");
    });

  export default {
    firestore: firebase.firestore(),
    auth: firebase.auth(),
    firebase: firebase,
    notificationSupported: firebase.messaging.isSupported(),
    messaging: firebase.messaging.isSupported() ? firebase.messaging() : null,
  };
  1. Add your firebase config keys
  2. Import config/firebase.js vue component