@capacitor/storage
The Storage API provides a simple key/value persistent store for lightweight data.
Mobile OSs may periodically clear data set in window.localStorage
, so this
API should be used instead. This API will fall back to using localStorage
when running as a Progressive Web App.
This plugin will use
UserDefaults
on iOS and
SharedPreferences
on Android. Stored data is cleared if the app is uninstalled.
Note: This API is not meant to be used as a local database. If your app stores a lot of data, has high read/write load, or requires complex querying, we recommend taking a look at a SQLite-based solution. One such solution is Ionic Secure Storage, a SQLite-based engine with full encryption support. The Capacitor Community has also built a number of other storage engines.
Install
npm install @capacitor/storage
npx cap sync