BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Ionic Capacitor: Creating Native Applications with JavaScript

Ionic Capacitor: Creating Native Applications with JavaScript

Leia em Português

This item in japanese

Bookmarks

Capacitor is a new development framework by Ionic for hybrid application creation. Capacitor provides an alternative to Apache Cordova, a well-established solution first released in 2009.

Ionic's decision to create an alternative to Cordova is due to two main factors: Cordova's outdated plugin system, and its restrictive approach to managing native platforms.

Cordova and Capacitor provide a plugin system that enables the communication between JavaScript and native platform capabilities, such as Bluetooth and RFID. In recent years, the Cordova plugin system has struggled to keep up with new technologies.

A good example would be the Swift language, released by Apple at the end of 2014 but added to the Cordova plugin system in 2019 (Swift was supported earlier by a third-party plugin).

An outdated plugin system can harm the entire ecosystem, mainly when the ecosystem relies heavily on third-party plugins.

The Capacitor plugin system provides a more straightforward development process that supports up-to-date technologies.

Since the Capacitor plugin ecosystem is still relatively small, developers can continue using the vast majority of Cordova plugins within Capacitor. This compatibility is a temporary solution to ensure developers do not lose access to essential platform capabilities.

Native project management is the second change Capacitor brings to the industry. Cordova generates native platform code at build time. Developers use a shared configuration file that includes instructions to build the application, which then gets used by Cordova during the native build process. This approach simplifies the build process at the cost of limited access to native projects.

While the solution provided by Cordova is easy to use and works well for small projects, it presents a challenge for larger, more complicated projects, which often require greater control over the native project code and configuration.

To solve this, Ionic Capacitor takes a less intrusive but more flexible approach. Capacitor generates and syncs the JavaScript code for the native platforms, but requires developers to manage the native platform code themselves directly. This native code management requires additional effort from developers, but provides greater control over the native aspects of their projects.

Both Cordova and Capacitor extend their reach beyond mobile applications, and now support the creation of PWA and desktop applications (with Electron), though the support of these capabilities is not as complete as their hybrid mobile application support.

Ionic Capacitor is open source software available under the  MIT license. Contributions are welcome via the Capacitor contribution guildines and contributors should follow the Capacitor code of conduct.

Rate this Article

Adoption
Style

BT