I made a simple web app with Vue.js and Firestore. I want to cache the web app and display the page even with no internet connection. I am not getting the desired results when I use the enablePersistence() method in the firebase configuration file in my Vue project built with PWA template. I tried to use that method in the lifecycle methods within the app components, still not getting the desired result.
Declaring it in your Firebase configuration file as follows should do the trick:
import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/auth';
var config = {
apiKey: ....,
authDomain: ....,
//.....
};
firebase.initializeApp(config);
const db = firebase.firestore();
const auth = firebase.auth();
db.enablePersistence();
export { db, auth };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With