Live presentation: Top 10 Ways to Launch a Successful Mobile Project
Capacitor comes with a Plugin generator to start new plugins quickly. To use it, run
npx @capacitor/cli plugin:generate
This starts a wizard prompting you for information about your new plugin. For example:
npx @capacitor/cli plugin:generate ✏️ Creating new Capacitor plugin ? Plugin NPM name (kebab-case): my-plugin ? Plugin id (domain-style syntax. ex: com.example.plugin) com.ionicframework.myplugin ? Plugin class name (ex: AwesomePlugin) MyPlugin ? description: ? git repository: ? author: ? license: MIT ? package.json will be created, do you want to continue? (Y/n)
Plugin NPM name: a kebab-case name of a package that will be available on npm (not a strict requirement if your package will be on a private npm repo).
Plugin ID: a domain-style identifier. It is primarily used for the package name in Java.
Plugin Class Name: the initial name of the class used in Java and Swift. See the additional note about class names in the iOS Plugin section of this guide.
description: a brief introduction about the plugin.
git repository: the URL to a git repository where the source code of the plugin will be hosted.
author(optional): the name of the plugin creator in
license(optional): the license under which the plugin is bound. MIT license is the default.
package.json will be created: enter “Y” and/or hit Enter/Return to finish plugin setup.
Now it’s up to you to make your plugin do something truly awesome! Read on to learn how to implement new functionality, test the plugin locally, and publish it on npm.