Skip to main content

Napacitor MAUI Documentation

Napacitor's native layer is not a per-platform native project. Instead, the native runtime is .NET MAUI Blazor (BlazorWebView + JSInterop): one C# codebase covers Android, iOS, Mac Catalyst, and Windows.

The MAUI host is generated and managed through the nap CLI, and configured through standard .NET MAUI project files. See What is .NET MAUI? and the .NET MAUI documentation for everything platform-specific.

Platform Support​

Napacitor supports every platform .NET MAUI 10 supports. The generated host targets:

PlatformTargetFrameworkMinimum OS
Androidnet10.0-androidAndroid 7.0 (API 24)
iOSnet10.0-iosiOS 17.0
Mac Catalystnet10.0-maccatalystmacOS 13.5
Windowsnet10.0-windows10.0.19041.0Windows 10 1809 (build 17763)

See the MAUI supported platforms reference for details, and Setting Target Frameworks for how the TFM relates to installed workloads.

How the MAUI Host Works​

The maui/ directory generated by nap add maui is a standard .NET MAUI Blazor Hybrid project:

  1. MainPage.xaml hosts a BlazorWebView that loads wwwroot/index.html, with the root component Main.razor mounted on #napacitor-root;
  2. Main.razor calls NapacitorRuntime.StartAsync(JS) after first render;
  3. The runtime discovers [NapacitorPlugin] plugins by reflection, injects the native bridge (window.Napacitor), reads napacitor.config.json, and imports your web entry scripts in the order recorded in napacitor.entries.json;
  4. Plugin calls go over window.DotNet.invokeMethodAsync('Napacitor', 'NAP_invoke', …); events are pushed back to the web view by the C# runtime.

Adding the MAUI Platform​

First, install the @napacitor/maui package in your web project.

npm install @napacitor/maui --save-dev

Then, add the MAUI platform. This generates the maui/ host from the built-in template (and auto-syncs if webDir has already been built):

npx nap add maui

Opening the MAUI Project​

To open the host project with your default tool, run:

npx nap open maui

Alternatively, open the maui/ directory in Visual Studio, Visual Studio Code, or Rider as a standard .NET MAUI project.

Running Your App​

You can run your app from the command line or from your IDE.

Running on the Command-Line​

npx nap run --target android # or ios / maccatalyst / windows

The --target resolves to the host's TargetFramework. Android and iOS -t:Run targets build, install, and start automatically; Windows has no such override — build first, then run:

npx nap build --target windows
npx nap run --target windows

Learn more in the CLI command reference.

Android requires an online device or emulator (adb devices must show status device), otherwise deployment fails with XA0010. iOS builds require macOS with Xcode installed. See Environment Setup.

Running with an IDE​

Open the maui/ project in your IDE, select the target device or emulator, and press Run/Debug. In Visual Studio, select a target framework from the run drop-down (e.g. net10.0-android).

Host Project Structure​

maui/
├── App.csproj # TargetFrameworks, ApplicationId, ApplicationTitle, MauiIcon/MauiSplashScreen
├── MauiProgram.cs # MAUI startup configuration
├── MainPage.xaml(.cs) # ContentPage hosting the BlazorWebView
├── Main.razor # Blazor root component (calls NapacitorRuntime.StartAsync)
├── wwwroot/ # your web build output (filled by nap copy/sync)
├── napacitor.build.props # generated by nap sync; wires plugin C# projects into the host
└── Platforms/ # per-platform files (AndroidManifest.xml, Info.plist, app.manifest, …)

Troubleshooting​

If you run into issues, consult the MAUI Troubleshooting Guide. Feel free to open an issue if you need help.

Next Steps​

If your app ran, you are ready to continue developing and building your app. Use the available plugin APIs, or write custom C# plugins to build out the rest of your app.

Further Reading​

Configuring and setting permissions ›

Setting Target Frameworks and managing workloads ›

Deploying to Google Play ›

Deploying to the App Store ›

Deploying to the Microsoft Store ›