メインコンテンツまでスキップ
バージョン: v2

Using Cordova Plugins and Ionic Native

When developing an app that uses Capacitor, it's possible to use both Cordova and Ionic Native plugins.

Installing Cordova Plugins

Simply install your plugin of choice, sync your project, finish any required native project configuration, and you're ready to go:

npm install cordova-plugin-name
npx cap sync

Updating Cordova Plugins

Similar to the installation steps. Simply update the cordova plugin to the latest version then Capacitor will pick up the changes:

npm install cordova-plugin-name@2
npx cap update

If you don't want to risk to introduce breaking changes, use npm update cordova-plugin-name instead of @2 as update respects semver.

Installing Ionic Native Plugins

Ionic Native provides TypeScript wrappers and a consistent API and naming convention for easier development with Cordova plugins. It's supported in Capacitor, so whenever you find an Ionic Native wrapper you'd like to use, install the JavaScript code, install the corresponding Cordova plugin, then sync your project:

npm install @ionic-native/javascript-package-name
npm install cordova-plugin-name
npx cap sync

Updating Ionic Native Plugins

Similiar to the installation steps. Update the Ionic Native JavaScript library, remove then re-add the Cordova plugin, then update your project:

npm install @ionic-native/javascript-package-name@2
npm install cordova-plugin-name@2
npx cap update

Determining Installed Plugin Version

See the list of Capacitor and Cordova plugins (and their exact version numbers) installed in your project with:

npx cap ls

Important: Configuration

Capacitor does not support Cordova install variables, auto configuration, or hooks, due to our philosophy of letting you control your native project source code (meaning things like hooks are unnecessary). If your plugin requires variables or settings to be set, you'll need to apply those configuration settings manually by mapping between the plugin's plugin.xml and required settings on iOS and Android.

Consult the iOS and Android configuration guides for info on how to configure each platform.

Compatibility Issues

Some Cordova plugins don't work with Capacitor or Capacitor provides a conflicting alternative. See here for details and a known incompatibility list.