Couchbase Lite for Data Storage in Ionic App Using Cordova Plugin
Join the DZone community and get the full member experience.Join For Free
At a high level, the architecture of a Cordova application that uses Cordova Plugins to access native code libraries is pretty straightforward.
- The WebView is used for rendering the web app
- The web app uses plugins to access native functionality. The Couchbase Lite Cordova Plugin is written in native platform language and is responsible for interfacing with Couchbase Lite. The plugin exposes a JS API that is accessible to the web app.
We have put together two tutorials, one for Android and one for iOS. Each tutorial will walk you through the steps on how you can build a Cordova plugin that will interface with Couchbase Lite 2.x on specific platform. This Couchbase Lite plugin will allow Cordova applications to use Couchbase Lite for data persistence. In our sample app, we will use for building our the frontend web app layer.
We will be working with a very simple app called the "Hotel-Lister." This app allows users to Query for and to display a list of hotels.
The hotels are queried for from a local pre-built Couchbase Lite database and displayed in the Ionic web app.
After completing the tutorial, you should have a good idea of how to use Couchbase Lite as a local data store within your Cordova Application on iOS and Android. Check out our tutorials site for more sample apps.
If you have questions or feedback, please leave a comment below or feel free to reach out to me at Twitter @rajagp or email me at. The Couchbase Forums are another good place to reach out with questions.
I would like to thank James Nocentini for his contributions to the tutorials and development of the sample apps.
Published at DZone with permission of Priya Rajagopal, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.