Have a look at Pouchdb.
PouchDB is an open-source JavaScript database inspired by Apache
CouchDB that is designed to run well within the browser.
It enables
applications to store data locally while offline, then synchronize it
with CouchDB and compatible servers when the application is back
online, keeping the user's data in sync no matter where they next
login.
So, it will meet your requirement "to store data offline and then sync it with online database". PouchDB is build on top of IndexedDB, so you will be able to take advantages of IDB.
With PouchDB, server side database has to be CouchDB, but still you can check with other server side database sync options are available. As per my knowledge there is no framework/library available which enables to sync SQL database.
If you have to sync client database data with only SQL server then you have write your own framework to do so, which means
- Using JS
setInterval
or some other mechanism to send client db data to server periodically
- Capture the delta (db updates once client is offline) and send it to server once client is back online.