Data Storage
There are a variety of options available for storing data within an Ionic application. It is best to choose options that best fit the needs of your application. A single application may have requirements that span multiple options.
Some storage options involve third-party plugins or products. In such cases, we neither endorse nor support those plugins or products. We are mentioning them here for informational purposes only.
Here are some common use cases and solutions:
Local Application Settings and Data
Many applications need to locally store settings as well as other lightweight key/value data. The Capacitor Preferences plugin is specifically designed to handle these scenarios.
Relational Data Storage (Mobile Only)
Some applications, especially those following an offline-first methodology, may require locally storing high volumes of complex relational data. For such scenarios, a SQLite plugin may be used. The most common SQLite plugin offerings are:
- Cordova SQLite Storage (a convenience wrapper also exists for this plugin to aid in implementation)
- Capacitor Community SQLite Plugin
Non-Relational High Volume Data Storage (Mobile and Web)
For applications that need to store a high volume of data as well as operate on both web and mobile, a potential solution is to create a key/value pair data storage service that uses indexedDB on the web and one of the previously mentioned SQLite plugins on mobile.
Here a sample of how this can be accomplished:
Other Options
Other storage options that provide local as well as cloud-based storage that work well within Capacitor applications also exist and may integrate well with your application.
For example: