# Offline Best Practice

**URL:** <https://forum.ionicframework.com/t/offline-best-practice/33779>\
**Category:** uncategorized\
**Created:** [October 3, 2015, 3:17pm UTC](https://forum.ionicframework.com/t/offline-best-practice/33779 "2015-10-03T15:17:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kanpouz](https://avatars.discourse-cdn.com/v4/letter/k/f6c823/32.png) [@kanpouz](https://forum.ionicframework.com/u/kanpouz)\
**Post date:** [October 3, 2015, 3:17pm UTC](https://forum.ionicframework.com/t/offline-best-practice/33779/1 "2015-10-03T15:17:25Z")

</div>

I’m so exited joining ionic community, I was able to publish my first app using this framework.

Now I’m ready to publish my 2nd version, however I have an issue:  
I have a controller that runs and $http.get statement to get a JSON file remotely, so far everything is great.

The issue is when the device is offline, I don’t want the user going to the index page until an internet connection is available.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![padz535](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/padz535/32/13364_2.png) [@padz535](https://forum.ionicframework.com/u/padz535)\
**Post date:** [October 5, 2015, 4:01am UTC](https://forum.ionicframework.com/t/offline-best-practice/33779/2 "2015-10-05T04:01:26Z")

</div>

You can make use of HTML5’s local storage.

I implemented my own version of this using factory.  
Feel free to take a look at it.

> <https://gist.github.com/renesansz/eb915298018a6da53895>

---

<div class="post-metadata">

**Author:** ![virender](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/virender/32/71454_2.png) [@virender](https://forum.ionicframework.com/u/virender)\
**Post date:** [October 5, 2015, 4:56am UTC](https://forum.ionicframework.com/t/offline-best-practice/33779/3 "2015-10-05T04:56:06Z")

</div>

You need to check internet is available or not ,

Use $cordovaNetwork.isOffline()

then run statement otherwise show custom message

Read this article about how to check internet in ionic framework

[http://www.codeandyou.com/2015/07/how-to-check-network-connection-in.html](http://www.codeandyou.com/2015/07/how-to-check-network-connection-in.html)
