How to sync data to DB when the user is back online

I am creating a To-Do app (over saturated i know), and need the app to store data locally if the app is offline. When the user connects back to the server, then that information that is stored locally, needs to be uploaded to the DB so that it can be used on other devices etc.

The problem at the minute is is that whatever data the user created when the app is offline, is lost forever on establishing connection.

Is there anyway I can add a service worker, plug in or anything to help me with this issue?

Thanks in advance

Are you trying to build a mobile app?

Not at the moment. This is browser based at the minute. However, if it loses connection, I want whatever the user has written ‘offline’ to be uploaded to the database once connected again.

I will look at making the app work on mobile once i get this issue sorted. A native app will be the way to go for this.

Can anyone help me?

Check out this these articles:

If you’re not a developer though, you’ll probably have to hire someone to set it up. Good luck.