Command-line interface for Capacitor cross-platform native runtime that enables building web apps for iOS, Android, and other platforms
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Capacitor CLI provides comprehensive plugin discovery, installation, and management for both Capacitor and Cordova plugins through command-line interfaces. Plugin management functions are handled internally and are not exposed as exportable functions.
List all installed Capacitor and Cordova plugins for the project.
Command:
npx cap ls [platform]Examples:
# List all plugins
npx cap ls
# List plugins for specific platform
npx cap ls ios
npx cap ls androidOutput: The command displays:
Create a new Capacitor plugin project with scaffolding.
Command:
npx cap plugin:generateThis command is interactive and will prompt for:
Example:
# Start interactive plugin generation
npx cap plugin:generatePlugins are typically installed through npm/yarn and automatically detected by Capacitor:
# Install a Capacitor plugin
npm install @capacitor/camera
# Install a Cordova plugin
npm install cordova-plugin-cameraAfter installing plugins, run sync to update native projects:
npx cap syncCapacitor plugins are configured in capacitor.config.ts:
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
appId: 'com.example.app',
appName: 'My App',
webDir: 'dist',
plugins: {
Camera: {
permissions: ['camera', 'photos']
},
PushNotifications: {
presentationOptions: ['badge', 'sound', 'alert']
}
}
};
export default config;Cordova plugins can be configured through:
const config: CapacitorConfig = {
// ... other config
cordova: {
preferences: {
ScrollEnabled: 'false',
BackupWebStorage: 'none'
}
}
};<preference name="ScrollEnabled" value="false" />
<preference name="BackupWebStorage" value="none" />Plugins can support different combinations of platforms:
The doctor command can help identify plugin compatibility issues:
# Check for plugin compatibility issues
npx cap doctor
# Check platform-specific plugin issues
npx cap doctor ios
npx cap doctor androidSync native projects:
npx cap syncUpdate dependencies:
npx cap updateCheck for issues:
npx cap doctorList installed plugins:
npx cap lsCheck plugin compatibility:
npx cap doctorClean and rebuild:
npx cap sync
npx cap build ios
npx cap build androidPlugins detected by Capacitor have the following structure:
interface Plugin {
id: string; // Plugin identifier
name: string; // Display name
version: string; // Installed version
rootPath: string; // Path to plugin directory
manifest?: PluginManifest; // Plugin manifest data
ios?: {
name: string;
type: PluginType;
path: string;
};
android?: {
type: PluginType;
path: string;
};
}
enum PluginType {
Core, // Official Capacitor plugin
Cordova, // Cordova plugin
Incompatible // Incompatible or problematic plugin
}Plugin management is implemented through internal modules:
/plugin.ts/android/ and /ios/ modules/cordova.tsThese internal functions are called by CLI commands but are not part of the public API.
Install with Tessl CLI
npx tessl i tessl/npm-capacitor--cli