Introduction
Apache Cordova wraps a web application inside a native container, giving HTML/CSS/JavaScript code access to device APIs through a plugin system. It allows web developers to build mobile apps for Android, iOS, and other platforms without learning platform-specific languages, while still accessing hardware features like the camera, GPS, and file system.
What Cordova Does
- Packages web applications as native mobile apps with a WebView container
- Provides JavaScript APIs to access native device features (camera, contacts, geolocation, file system) via plugins
- Supports Android, iOS, and browser platforms from a single HTML/CSS/JS codebase
- Offers a CLI for creating projects, adding platforms, building, and running apps
- Maintains a plugin ecosystem where the community publishes reusable native-to-JS bridge modules
Architecture Overview
Cordova apps run inside a native WebView component on each platform. The Cordova bridge sits between JavaScript code in the WebView and native platform code. When JavaScript calls a Cordova plugin API, the bridge serializes the request, dispatches it to the native plugin class (Java on Android, Objective-C/Swift on iOS), executes the native operation, and returns the result back to JavaScript via a callback or promise. The config.xml file defines app metadata, platform settings, and plugin declarations.
Self-Hosting & Configuration
- Install Node.js and npm, then install Cordova globally with npm install -g cordova
- For Android builds, install Android Studio, the Android SDK, and set ANDROID_HOME environment variable
- For iOS builds, install Xcode and its command-line tools on macOS
- Configure app settings (name, version, permissions, icons, splash screens) in config.xml at the project root
- Add plugins via cordova plugin add and manage platform versions via cordova platform add/update
Key Features
- Write once in HTML/CSS/JS and deploy to Android, iOS, and browser platforms
- Extensible plugin architecture for accessing any native API not covered by core plugins
- Hooks system for customizing the build pipeline at various lifecycle points
- Mature ecosystem with hundreds of community-maintained plugins on npm
- No vendor lock-in as it is an Apache Software Foundation project with an open governance model
Comparison with Similar Tools
- Capacitor — Ionic's successor to Cordova; uses a similar WebView approach but with a modern plugin API and better native project integration
- React Native — renders native UI components instead of a WebView; better performance for complex UIs but requires learning React Native APIs
- Flutter — compiles to native ARM code with its own rendering engine; higher performance but requires learning Dart
- Ionic — a UI framework often used on top of Cordova or Capacitor; provides pre-built mobile UI components
- NativeScript — direct access to native APIs from JavaScript without a WebView; smaller community than React Native
FAQ
Q: Is Apache Cordova still actively maintained? A: Yes. The Apache Cordova project continues to release updates to the CLI, core plugins, and platform libraries, though the pace has slowed compared to its peak years.
Q: What is the difference between Cordova and PhoneGap? A: PhoneGap was Adobe's commercial distribution of Cordova with additional cloud build services. Adobe discontinued PhoneGap in 2020, but the open-source Cordova project continues independently.
Q: Can Cordova apps access native device features? A: Yes, through plugins. Core plugins cover camera, geolocation, file system, contacts, and network status. Custom plugins can bridge any native API to JavaScript.
Q: How does Cordova performance compare to native apps? A: Cordova apps run in a WebView, so they are subject to web rendering performance constraints. For content-driven apps and simple interactions, performance is acceptable. For graphics-intensive or animation-heavy apps, native or compiled frameworks like Flutter perform better.