Search code examples
angularcordovaionic-frameworkprogressive-web-appscapacitor

Capacitor storage or cordova storage


I'm developing a PWA application with ionic v5 and I need to save some content offline to present to users. I'm thinking to use Capacitor to publish my web application into a native app as an alternative to Cordova, but the data storage is an important point of my application. Are capacitor storage and Cordova storage the same?


Solution

  • For PWAs: Capacitor Storage falls back to using localStorage. While Ionic Storage (utilizing Cordova) uses IndexedDB, WebSQL, and localstorage, in that order.

    Are capacitor storage and Cordova storage the same?

    Briefly: No. Storage highly depends on the platform your app is running on. Capacitor and Cordova take on a different approach in this regard. They will automatically use the appropriate local storage system for each platform.

    How to choose storage for Native Apps:

    1. For High Performance Storage: Use Ionic Storage that uses Cordova SQLite plugin. It is key-value based access but uses SQLite underneath by default. Howeever, when running in the web or as a Progressive Web App, Storage will attempt to use IndexedDB, WebSQL, and localstorage, in that order.

    2. For casual storage: If you want to store data that should be persistent but does not require high level of querying, then use Capacitor Storage. It will use UserDefaults on iOS and SharedPreferences on Android. But, this API will fall back to using localStorage when running as a Progressive Web App.

    3. For UnImportant Data: You can simply use localStorage and don't need any additional storage engine.