DEV Community

Roger K.
Roger K.

Posted on

IndexedDB, something to rely upon?

Could I build a Progressive Web App using IndexedDB as my sole form of storage?

My supposition is to build a suite of apps that work together and are local; calendar, tasks, contacts, etc that run exclusively inside the browsers domain. They don't need to install an 'app', they don't need a web service to function. Just go toa webpage, click add to desktop an like Dev.to and voila it works.

Can this be done? Why hasn't this become common? What are the risk factors?

More specifically, I'm clearly going to rely on IndexedDB, right? Is that bad/good? Why?

I'm sure there are reasons for why this hasn't happened, but if I could I'd like to aggregate all the feedback into this one article for myself and others who may be considering the same thing.

Your assistance is greatly appreciated!!

Top comments (5)

Collapse
 
rhymes profile image
rhymes

Why do you say it is not used?

Anyhow IndexedDB has a complicated API, even Mozilla suggests using a wrapping library:

mdn

Collapse
 
misterhtmlcss profile image
Roger K.

Nice. Thanks for the tip.
By the way I know it's used per say, but what I'm saying is look at my examples and I don't see anything built like that. Not sure if I'm making myself understood or not.

Collapse
 
rhymes profile image
rhymes

Don't know, it's not easy to know how much IndexedDB is used. You would need to check web apps and see where they store their data. That's a daunting task :D

Checking the wrappers usage it would probably be easier:

  • dexie.js (IndexedDB only) has 3k stars on github, 15k weekly downloads
  • localForage (multiple backends, defaults to IndexedDB) has 15k stars and 133k weekly downloads
  • pouchdb (multiple backends, defaults to IndexedDB) has 11k stars and 14k weekly downloads

someone must be using them :D

Collapse
 
zimba profile image
Martin • Edited

It's not very common because there are other better ways to achieve the same.

If wanna build an web app (or PWA) with offline storage, these are the options:

1) Chrome Apps

  • Pros:

    • Delivering the app to the user is much easier. Chrome Web Store will take care of it.
    • Releasing new version and keep the app up-to-date is much easier (chrome will take care of it).
    • You can even sell the app with Web Store (paid apps).
    • Stable Api's and guaranteed to work with Chrome.
  • Cons:

    • If you're developing an internal tool or web app, then the delivering the app to user requires some effort.
    • Your app is tied to Chrome browser and the browser needs to be installed in the first place.
    • If you already built the app with some framework, then you need to modify the codebase to use chrome api.

2) Electron App

  • Pros:

    • You can use easily convert any modern web app into an Electron App.
    • Standalone app which doesn't depend on Chrome or any other browser.
    • If it's an internal tool to your company or you wanna monetize it in different way. Then this is the best option.
    • You're free to use any type of marketplace to distribute the app (like Apple App Store or Microsoft Store).
    • Stable Web Api, since your shipping the entire browser with your app.
  • Cons:

    • Delivering the app become painful (if you've couple thousand users) and you don't want to use App Store.
    • You need to have your own way to support payment if it's paid app.
    • You need to use build tools like webpack to build the electron app. if webapp is too simple (like plain html app), then it'll increase the complexity of the app.

All of these options (including yours) supports the both LocalStorage & Indexeddb storage.

Collapse
 
avalander profile image
Avalander

It's worth noting that Google has deprecated chrome apps for desktop (except in chrome OS) and electron doesn't support mobile platforms, so those options don't cover all the use cases one might want for an offline web app.