Napacitor Workflow
Working with Napacitor is slightly different than working with a traditional web app. To make your web app a native Napacitor application, you'll need to do the following steps.
Building your web code
Once you are ready to test your web app on a device, you'll need to build your web app for distribution. If you are using a tool like Vite that command will be npm run build. Whatever your command is, you will need to build your web code for distribution in order to use it with Napacitor.
Syncing your web code to the MAUI host
Once your web code has been built for distribution, you will need to push your web code to the native MAUI host. To do this, you can use the Napacitor CLI to "sync" your web code into the host's wwwroot/ and regenerate napacitor.build.props, which wires the installed plugins' C# projects into the host.
To sync your project, run:
npx nap sync
Running npx nap sync will copy over your already built web bundle to the host and update the host's plugin references.
You can read our docs on sync and more on the Napacitor CLI reference documentation.
Did you get an error about "not being able to find the web assets directory?" Update your Napacitor configuration file to use the proper webDir.
Testing your Napacitor app
Once you've synced over your web bundle to the host, it is time to test your application on a device. There are a few different ways to do this, but the easiest way is to use the built in Napacitor CLI commands.
To run a debug build of your Napacitor app on an Android device, you can run:
npx nap run --target android
Similarly, on Windows (build first, then run):
npx nap build --target windows
npx nap run --target windows
For iOS / Mac Catalyst (on macOS), use --target ios or --target maccatalyst.
Once you've iterated and tested your application, it is time to compile the final binary to distribute to other devices.
You can also run your app from your IDE — Visual Studio, Visual Studio Code, or Rider. Both options are valid for development. Go ahead and try both to see which option you prefer!
Open the host project in your IDE
If you'd like more control over the host project you can quickly open it with the Napacitor CLI:
npx nap open maui
Opening the host project can give you full control over the native runtime of your application. You can create plugins, customize the host project, or compile your application for releasing.
Compiling your native binary
After sync, you are encouraged to open the host project in your IDE, or use the CLI to build the app:
npx nap build --target android -c Release
Publishing guides walk through producing store-ready artifacts for the Apple App Store, Google Play, and the Microsoft Store.
Updating Napacitor
Updating your Napacitor runtime is as straightforward as running npm install.
npm i @napacitor/core @napacitor/maui
npm i -D @napacitor/cli
After updating, run npx nap sync so the host references the updated C# sources. Napacitor packages are all released with the same version at the same time, meaning that if you install all of the libraries at the same time, you'll be fine! See the upgrade guide for details.
You can subscribe to the Napacitor repo to be notified of new releases. At the top of the repository index, click Watch -> Releases only.