When should we use Web SQL or IndexedDB? What are the use cases?

Utsav Sinha picture Utsav Sinha · Sep 26, 2017 · Viewed 8.3k times · Source

Recently I have come across Web SQL and IndexedDB provided by browsers. I want to understand the use cases when these can be used.

Answer

Hakan picture Hakan · Apr 22, 2018

Web SQL is deprecated per https://www.w3.org/TR/webdatabase/.

You can use IndexedDB if you need to store structured client specific data that you do not store in the server side or you do not want to request from the server every time.

Also as opposed to localStorage, IndexedDB is async so it is more performant. It supports indexing resulting in more efficient querying than localStorage which is simply a key-value store. However, if your needs are simple, localStorage might be a better option.

Here is a link that talks about different web storage options. Here is a tutorial about how to use IndexedDB for a progressive web app.