8

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?

Faizal
  • 353
  • 3
  • 16

1 Answers1

5

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.

Jeff Posnick
  • 53,580
  • 14
  • 141
  • 167
  • I think IndexedDB isn't persistent -- because it may be evicted without asking the user if free disk space runs low on the device. – ChrisW Feb 20 '22 at 12:07