Skip to content
jevonsflashPublic

About

A cross-platform native runtime for web apps, built on .NET MAUI.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Napacitor

License codeSize AtomGit G-Star

English | 中文

Napacitor is a cross-platform native runtime that lets you use modern web tooling to easily build high-performance native apps for Android, iOS, Windows, and macOS. Napacitor is heavily inspired by Capacitor. The difference is that its native abstraction layer is .NET MAUI Blazor rather than a separate native project for each platform, so a single, clean C# runtime drives all platforms.

Napacitor's main features are:

  • Hybrid development: Build apps with the web technologies you already know (vanilla JavaScript, HTML, CSS, or React, Angular, Vue), run them on iOS, Android, Windows, or macOS, and deploy easily to the App Store, Google Play, or the Microsoft Store.

  • Native access: A cross-platform API and code execution layer makes it easy to call native SDKs from web code, and lets you write custom native plugins your app may need.

  • .NET empowerment: The UI layer keeps using npm, TypeScript, and your favorite frameworks; the native layer brings in the C# ecosystem and engineering practices.

Quick Start

1. Add Napacitor to any existing web app

npm i @napacitor/core
npm i -D @napacitor/maui @napacitor/cli

2. Initialize, sync, and create the native runtime environment

Specify the app ID, name, and web build output directory. Napacitor generates an MAUI project and packages plugins automatically.

npx nap init com.example.app "My App" --web-dir dist
npx nap add maui

3. Run on any platform

Choose the target platform: android / ios / maccatalyst / windows.

npx nap run --target android

Plugin System

Each official plugin wraps a .NET MAUI native API in a consistent, Promise-based JavaScript interface. You can also create custom plugins as needed.

Plugin npm package Description Source / Docs
Action Sheet @napacitor/action-sheet Native action sheet that slides up from the bottom of the screen (Page.DisplayActionSheet). plugins/action-sheet
App @napacitor/app High-level app state and events: lifecycle, deep links, language, exit. plugins/app
App Actions @napacitor/app-actions Quick actions on the app icon (Android App Shortcuts, iOS Quick Actions, Windows jump lists). plugins/app-actions
App Info @napacitor/app-info General app information (AppInfo, VersionTracking). plugins/app-info
App Launcher @napacitor/app-launcher Open other apps, URLs, and maps (Launcher, Map). plugins/app-launcher
Battery @napacitor/battery Battery level and charging status. plugins/battery
Browser @napacitor/browser In-app browser sessions (Android Custom Tabs, iOS SFSafariViewController). plugins/browser
Camera @napacitor/camera Take photos, record video, and pick from the media library (MediaPicker). plugins/camera
Clipboard @napacitor/clipboard Copy to and paste from the system clipboard. plugins/clipboard
Connectivity @napacitor/connectivity Network status and connectivity change events. plugins/connectivity
Contacts @napacitor/contacts Read all contacts and use the system contact picker (Contacts). plugins/contacts
Database SQLite @napacitor/database-sqlite Local SQLite database: create tables, CRUD operations, transactions (Microsoft.Data.Sqlite). plugins/database-sqlite
Device @napacitor/device Device model, platform, OS version, language, and region. plugins/device
Dialog @napacitor/dialog Native alert, confirm, and prompt dialogs. plugins/dialog
Display @napacitor/display Screen metrics, display change events, keep screen awake, and orientation lock. plugins/display
Email @napacitor/email Open the system email compose screen. plugins/email
File Viewer @napacitor/file-viewer Open files with the system viewer. plugins/file-viewer
Filesystem @napacitor/filesystem App directories, bundled files, and the system file picker (FileSystem, FilePicker). plugins/filesystem
Flashlight @napacitor/flashlight Control the device flashlight (torch). plugins/flashlight
Geolocation @napacitor/geolocation Get and track the device's GPS location. plugins/geolocation
Haptics @napacitor/haptics Haptic and vibration feedback. plugins/haptics
Local Notifications @napacitor/local-notification Send system notifications immediately or on a schedule, with permission requests, cancellation, and tap callbacks. plugins/local-notification
Motion @napacitor/motion Accelerometer, gyroscope, magnetometer, compass, and barometer sensors. plugins/motion
Phone Dialer @napacitor/phone-dialer Open the system dialer to place a phone call. plugins/phone-dialer
Preferences @napacitor/preferences Lightweight key-value persistent storage. plugins/preferences
Security @napacitor/security Store secrets with OS-level security facilities (iOS Keychain, Android Keystore, Windows DPAPI). plugins/security
Share @napacitor/share Share content through the system share sheet. plugins/share
SMS @napacitor/sms Open the system SMS compose screen. plugins/sms

For custom plugins, see the "Build a Napacitor Plugin" chapter in the official docs: Build a Napacitor Plugin

How It Works

Architecture

alt text

Unlike Capacitor, which maintains a separate native project for each platform, Napacitor's native layer is .NET MAUI Blazor (BlazorWebView + JSInterop). A single C# runtime covers Android, iOS, Mac Catalyst, and Windows.

Web app (dist/ + napacitor.config.json + node_modules/@napacitor/*)
        │  nap add maui / nap sync
        ▼
MAUI Blazor host (maui/: App.csproj, BlazorWebView, wwwroot/, napacitor.build.props)
        │
        ▼
Napacitor runtime + plugins (C#, discovered via reflection)
        │  JS ⇄ DotNet.invokeMethodAsync('Napacitor', …)
        ▼
.NET MAUI 10 (net10.0-android / -ios / -maccatalyst / -windows)

Host Startup Flow

  1. The BlazorWebView generated from the template loads wwwroot/index.html, and the root component Main.razor mounts to #napacitor-root;
  2. After its first render, Main.razor calls NapacitorRuntime.StartAsync(JS);
  3. The runtime discovers [NapacitorPlugin] plugins via reflection, injects the native bridge window.Napacitor, reads the config, and loads the web entry scripts in the order defined by napacitor.entries.json;
  4. Plugin calls are sent via window.DotNet.invokeMethodAsync('Napacitor', 'NAP_invoke', …) and return a {"ok":true,"data":…} envelope; native events are pushed back into the WebView via NapacitorNative.__emit.

Supported Platforms

Platform TargetFramework Minimum OS version
Android net10.0-android Android 7.0 (API 24)
iOS net10.0-ios iOS 17.0
Mac Catalyst net10.0-maccatalyst macOS 13.5
Windows net10.0-windows10.0.19041.0 Windows 10 1809 (build 17763)

Requirements

  • Node.js 18+ (for the nap CLI)
  • .NET 10 SDK, with the MAUI workload installed: dotnet workload install maui
  • Windows: Windows 10 1809+ or Windows 11
  • Android: Android SDK (can be specified via ANDROID_HOME); running requires an emulator or a physical device with USB debugging enabled
  • iOS / Mac Catalyst: requires macOS + Xcode, and dotnet workload install ios maccatalyst

For more details, see the Environment Setup chapter in the docs.

Documentation

Official documentation

About

A cross-platform native runtime for web apps, built on .NET MAUI.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages