Originally published at: Data Storage in Ionic: How to Choose the Solution That Works For You
This is a guest post from Simon Grimm, Ionic Insider and educator at the Ionic Academy. Simon also created the Practical Ionic book, a guide to building real world Ionic applications with Capacitor and Firebase. You want to store data locally in your Ionic application? It’s a simple task usually, given the available tools these…
localForage-CordovaSQLiteDriver has not been maintained for the last 4 years.
Some errors begins to appears. For example: thgreasi/localForage-cordovaSQLiteDriver#39
Can we use any other library with a better maintenance?
Should we move to Capacitor Storage?
@juannooddle I use the Capacitor Plugin For SQLite, here is some content and full source code for Vue and React
Ionic React SQLite - Working With Ionic Framework And Capacitor - YouTube
Ionic Vue SQLite With Ionic Framework, and Capacitor - YouTube
Thank you for the article, really useful for an Ionic newbie like me!
Just wanted to ask for a clarification, when it says in the article
If your app is only using localstorage or IndexedDB, the underlying OS might clear your data at any time which makes these options not 100% persistent and safe.
under the “Ionic Storage” heading, is this a problem only if using localstorage or IndexedDB directly, or also in the case of using Ionic Storage?
Also with Ionic Storage as it uses IndexedDB
and localstorage
where available under the hood.
Can’t navigator.storage.persist()
be used to ensure persistent storage?
I asked about navigator.storage.persist()
on stackoverflow here and got this answer so i’m guessing it should work?
Grateful for any help with this!
On another note: I found this in another stackoverflow answer:
PWA are not affected by the 7days of unused rule. I have no issue storing datas in Indexeddb for months in my PWA, both on iOS and Android.
— What is data persistence status on iOS 16.6 and latest safari? - Stack Overflow
A PWA though is not a Capacitor app. I wouldn’t trust the OS keeping the data around forever as from what I know, it isn’t 100% guaranteed. I use Ionic Storage but our app doesn’t solely rely on it. If it is wiped, the data gets repopulated from our backend API.