title: How to enable offline data in firestore for web
body: <p>I want to enable offline data in my project.
  I found the right code for this but I don't know where to implement the code</p>
  
  <p>I implement the code inside the <code>firebaseConfig.js</code> file:</p>
  
  <pre><code>import firebase from 'firebase'
  import 'firebase/firestore'
  
  // firebase init
  // init code goes here
  var config = {
   apiKey: '',
   authDomain: '',
   databaseURL: '',
   projectId: '',
   storageBucket: '',
   messagingSenderId: ''
  } 
  firebase.initializeApp(config)
  
  firebase.firestore().enablePersistence()
   .then(function () {
     // Initialize Cloud Firestore through firebase
     var db = firebase.firestore();
   })
   .catch(function (err) {
     console.log(err)
   })
  
   // firebase utils
   const db = firebase.firestore()
   const oldRealTimeDb = firebase.database()
   const auth = firebase.auth()
   const currentUser = auth.currentUser
  
   // date issue fix according to firebase
   const settings = {
     timestampsInSnapshots: true
   }
   db.settings(settings)
  
   // firebase collections
   const usersCollection = db.collection('users')
   const postsCollection = db.collection('posts')
  
  export {
   db,
   auth,
   currentUser,
   postsCollection,
   usersCollection
  </code></pre>
  
  <p>}</p>
  
  <p>main.js</p>
  
  <pre><code>import Vue from 'vue'
  import App from './App.vue'
  import router from './router'
  import {store} from './store'
  import './registerServiceWorker'
  import Vuetify from 'vuetify'
  import 'vuetify/dist/vuetify.min.css' // Ensure you are using css-loader 
  const fb = require('./firebaseConfig.js')
  
  Vue.config.productionTip = false
  
  export const bus = new Vue()
  
  Vue.use(Vuetify)
  
  let app
  fb.auth.onAuthStateChanged(user =&gt; {
   if (!app) {
    app = new Vue({
     el: '#app',
     store,
     router,
     template: '&lt;App/&gt;',
     components: {
       App
     },
     render: h =&gt; h(App)
   }).$mount('#app')
  }
  })
  </code></pre>
  
  <p>I got this error:</p>
  
  <p><a href="https://i.stack.imgur.com/3egEn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3egEn.png" alt=""></a></p>