Angular 2/TypeScript/Phonegap/Couchbase Lite

This is a getting started question. We have an Angular 2 mobile app using Phonegap. I’ve added couchbase-lite-phonegap-plugin to our pgdata/ I was looking for an Angular 2 library that would provide the Typings for the Native API. The only thing I found was a NativeScript binding for Cordova. Can somebody point me to a project using Couchbase Lite with an Angular 2/TypeScript/Phonegap stack? My guess is that we must use the Rest API. Is that correct?

1 Like

Yes, you call the REST API. CBL PhoneGap apps typically use a little JS library called “coax” that’s a thin wrapper around the REST API; it should be packaged along with the plugin, or in any of our PhoneGap sample apps.

You can also use the Swagger client. There’s documentation [here] about it.(

Thanks. I was really hoping the Typings were generated somewhere like they are on Definitely Typed for other Cordova Plugins ( That way I could have done something like this in my typings.json file:

"globalDependencies": {
    "cordova/plugins/couchbaselite": "github:DefinitelyTyped/DefinitelyTyped/cordova/plugins/CouchBaseLite.d.ts",

There isn’t really a single official JS API for Couchbase Lite (or for CouchDB, to my knowledge.) We consider coax more of a handy utility than an official required component of the product.

coax may not play very nicely with TypeScript because (IIRC) it’s very loosely typed — mostly you pass freeform objects that get marshalled into JSON in the XHR requests. There’s been some talk of creating a more traditional API in JS, that matches the classes and concepts of our other APIs for Java/C#/Obj-C, but it hasn’t happened yet.

We can type them as “any” or just do REST calls. Thanks!