Add offline mode to your app

POS has a very neat offline mode. It seems to be a good function to integrate into existing and new apps like production orders and hr?
Could someone direct me to code where this is and how it works?

@LifeP,

Sales invoice in POS are saved in local storage when in offline mode, you can try to do the same for your app.

Please check the create_invoice method in pos.js

Actually I’m trying to create a small work log app which will pass task and time to timesheet.
I am only very new at programming. As this needs to works offline, I wanted to know best practice for this to sync with ERPNext.
Should I create a database locally and then sync directly to table in erpnext server?
or should is there some better way?