Progressive web application with persistent local database

3.7k Views Asked by At

What is the best choice for local database when implementing a progressive web application?

Initially the choice was to design a smart client desktop application with one click deployment that will install a local SQLite database. Local database can be then synced with the server side SQL database using Microsoft Sync Framework.

However with the future use cases to support mobile devices, I am more interested in developing a progressive web application with local SQL db to support offline mode (for users without any internet connection).

Considering the react PWA stack, I could not find a clean implementation with SQLite. IndexDB is available however it is not SQL like.

Any feedback on how to implement PWA offline mode with persistent local SQL database?

1

There are 1 best solutions below

1
Jeff Posnick On

The "best" choice that offers the widest support is IndexedDB. The IndexedDB API isn't particularly pleasant to use, so I normally turn to either https://github.com/jakearchibald/idb (for a full feature set) or https://github.com/jakearchibald/idb-keyval (for basic key/value use cases) as a higher-level, Promise-compatible wrapper.

There are techniques like https://jlongster.com/future-sql-web that attempt to bring other database engines to the web platform, but the downside is that they rely on external libraries and Web Assembly.