Getting Started
The @nxtend/capacitor
plugin will be added to your workspace and a Capacitor project will be automatically generated with a new @nxtend/ionic-react
application. However, you can add Capacitor to an existing project.
#
Install Plugin#
Add Capacitor to Existing ProjectFirst, ensure that the frontend project has been built:
Once the plugin has been added to your Nx workspace you can generate a Capacitor project from an existing frontend project:
Nx will ask you some questions about the application, but you can customize it further by passing these options:
Finally, you will need to cd
into your applications directory and install the npm dependencies. (e.g. npm install
)
#
Add Native PlatformsNow that a Capacitor project has been added to your Nx workspace you can begin adding support for native platforms. Currently, Capacitor supports Android and iOS, but other platforms can be added with Capacitor plugins.
#
Sync Native PlatformRunning the sync command will update the native platform dependencies and copy a build of your frontend project to the Capacitor project:
#
Open Native PlatformFinally, you can open the native platform in it's respective IDE:
#
Adding Capacitor PluginsCapacitor plugin dependencies must be added to the project-level package.json
.
To learn more about Capacitor, including the native API's available, please read the official Capacitor documentation.