Progressive web application with persistent local database
Asked Answered
S

1

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?

Spew answered 5/7, 2021 at 15:42 Comment(0)
Q
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.

Quassia answered 3/9, 2021 at 17:45 Comment(1)
I think IndexedDB isn't persistent -- because it may be evicted without asking the user if free disk space runs low on the device.Fulvia

© 2022 - 2024 — McMap. All rights reserved.