Great example on how to use Service Worker sync to make your app work offline by placing messages on IndexDB as queue and syncing when there's connectivity back.
The code is quite direct and can almost be copy and pasted to adapt to your app. I'm adding this functionality for my micropub editor.
One caveat, the IDB library for accessing IndexDB doesn't work well in Firefox and it is because of Firefox :(