Using Local Forage with Appgyver

Posted on Jan 7, 2015

Appgyver (as it is currently called at the time of this post) provides a tech stack that empowers developers to create a hybrid mobile app for Android and iOS. Built on PhoneGap, Cordova, Steroids, Ionic, and some others libraries, it integrates well with Angular. However, when it comes to storing your data, you are a bit limited in your options. Appgyver has native, easy to use integration for Built and Parse, or you can manually set up a REST API source rather easily. However, when it comes to wanting to store your database locally, Appgyver recently removed the option to SQLite as an easily integrated option.

Local Option for Storing Data

This recently left me looking for another option during a recent project. Ideally, the database would be downloaded while installing/downloading the app for fast and potentially offline searching of data. At the time, the database was about 12 MB, which made it too large to store completely in Local Storage with a 5 MB maximum.

However, browsers have other database options built in that are similar to local storage. There is WebSQL, as well as IndexedDB. These key/value databases allow invisible storage up to 50 MB. The limit can be increased with user permission. Unfortunately, WebSQL is the older technology and not as well supported, but not all browsers support IndexedDB either.

What is Local Forage?

Local Forage is a polyfill library developed by Mozilla that use the optimum database depending on the browser being used. In the event that neither WebSQL or IndexedDB are available, it will fall back to Local Storage. To use this with Appgyver, we opted for the angular-localForage library, which heavily leverages promises for setting and getting data. Actually, almost every operation using angular-localForage returns a promise, which is great when working with Angular.


The downside of using the Local Forage polyfill is that it caters to the lowest common denominator of Local Storage, which does not support multiple tables per database. So while you can create a new table in IndexedDB per Angular module, you won’t necessarily be able to access them individually. Also, while looking up individual records is really fast, searching the database for the specific record you need based on a subproperty of your object can be a bit slow.

Why We Dropped Local Forage

We had a lot of fun working with Local Forage, but ultimately it did not meet our needs. We were able to optimize our Rails API to return data much faster than loading data from Local Forage based on the way our app worked. However, if you are looking for a simple way to package your data with your Appgyver-based app with easy CRUD capabilities, Local Forage may be the compromise you are looking for.

Submit a Comment

Your email address will not be published. Required fields are marked *