Localforage vs Localstorage
So, whats the difference between localforage and localstorage? And why do people recommend localforage rather then localstorage?
Its quite simple actually.
Localforage
Localforage is an asynchronous based local database simular to localstorage but internally it uses IndexedDB.
IndexedDB is an arguably better alternative to localstorage, the problem is its kinda complex.
Localforage has a simple localstorage like syntax for IndexedDB.
Localforage also has a fallback to other storage methods for old browsers.
It's good for saving large data as IndexedDB has more storage then localstorage.
Localstorage
Localstorage is a synchronous based local database.
You don't need to use promises/async syntax for it.
It has a lot less storage then IndexedDB.
It's great for saving user settings without using cookies.
Conclusion
Its ultimately your choice.
I personally recommend localstorage for simply saving settings like dark mode, etc but i recommend localforage for saving data that is large in size, or if you can only use async in the current situation.
Top comments (0)