Plugins & Native Modules
zero-native keeps the core runtime small by shipping optional native features as plugins. If your app doesn’t include a plugin, it pays 0 bytes — and the OTA capability manifest automatically tracks every plugin your bundle uses so older app binaries never crash from a missing native module.
1. Official Plugins
Section titled “1. Official Plugins”All 20 official plugins live under plugins/ with individual READMEs for detailed API docs. (17 have native implementations on both Android and iOS. markdown is pure JS, android-play-auth answers “unavailable” on iOS, and android-ad-id is Android-only.)
| Plugin | Android | iOS | What it provides |
|---|---|---|---|
@zeronative/scanner |
✅ | ✅ | QR & barcode scanner (<QrScanner>, CameraX + bundled ML Kit / AVFoundation) with stale-frame protection |
@zeronative/document-scanner |
✅ | ✅ | Paper document camera scanner with edge detection & process-kill recovery |
@zeronative/pdf |
✅ | ✅ | Native PDF viewer & downloader (PdfRenderer / PDFKit) |
@zeronative/webview |
✅ | ✅ | Embedded web view (<WebView>) with navigation interception & origin-checked JS bridge |
@zeronative/image-viewer |
✅ | ✅ | Full-screen zoomable photo viewer (ImageViewer.open(...)) |
@zeronative/lottie |
✅ | ✅ | Lottie animations (lottie-react-native API) |
@zeronative/markdown |
✅ (JS) | ✅ (JS) | Pure-JS Markdown rendered as native <Text> & layout components |
@zeronative/location |
✅ | ✅ | GPS coordinates & geocoding |
@zeronative/media |
✅ | ✅ | Photo/file picker, camera capture, native resize/compress/crop |
@zeronative/notifications |
✅ | ✅ | Local notifications, scheduling, action buttons, channels/threads (Notifee-like API) |
@zeronative/device-info |
✅ | ✅ | Device model, OS version, app version, build number (react-native-device-info style) |
@zeronative/app-updates |
✅ | ✅ | Store update prompts (Google Play In-App Updates on Android; App Store link on iOS) |
@zeronative/android-play-auth |
✅ | stub | Android phone number hint & SMS Retriever autofill (returns unavailable on iOS) |
@zeronative/android-ad-id |
✅ | — | Google Advertising ID for attribution |
@zeronative/firebase-app |
✅ | ✅ | Shared Firebase base required by Firebase plugins |
@zeronative/firebase-crashlytics |
✅ | ✅ | JS & native crash reporting |
@zeronative/firebase-analytics |
✅ | ✅ | Event & user property analytics |
@zeronative/firebase-messaging |
✅ | ✅ | FCM / APNs push tokens, topics, data messages, native OTA-check push |
@zeronative/firebase-remote-config |
✅ | ✅ | Remote Config fetch & activation |
@zeronative/firebase-perf |
✅ | ✅ | Network & custom performance traces |
2. Adding an Official Plugin to Your App
Section titled “2. Adding an Official Plugin to Your App”While building from a local zero-native checkout, wire a plugin in four places:
- JS (
package.json): Add"@zeronative/<name>": "link:../zero-native/plugins/<name>"and runbun install. - Android (
android/settings.gradle.kts+android/app/build.gradle.kts): In azn newapp, add adependencySubstitutionentry insettings.gradle.ktsmappingio.github.zero-native:plugin-<name>to:plugin-<name>, then addimplementation("io.github.zero-native:plugin-<name>")inapp/build.gradle.kts. - iOS (
ios/CMakeLists.txt): Add the plugin folder name toAPP_ZN_PLUGINS(or, when using SwiftPM, select theZnPlugin<Name>product: from the zero-native package, except the Firebase plugins and Lottie, which come from thezero-native-firebaseandzero-native-lottiepackages at the same version; in a local checkout,ios/packages/firebaseandios/packages/lottie. Seedocs/releasing.md). - Register at startup: Register the plugin in Android
MainApplication.ktand iOSAppDelegate.swift(ZnPlugins.register(...)).
In an app on the published packages (made by zn new from npm, once 0.1.0 is out), a plugin goes in three places,
all at the app’s zero-native version (say 0.1.0; zn build stops when one differs):
- JS:
bun add --exact @zeronative/<name>@0.1.0. Without--exact, Bun writes^0.1.0, whichzn buildrefuses: an update could then move the JS without the native side. - Android (
android/app/build.gradle.kts):implementation("io.github.zero-native:plugin-<name>:0.1.0"), from Maven Central. Nosettings.gradle.ktschange. Like the runtime, each plugin has a debug and a release build, so a build type of your own needsmatchingFallbacks(Getting Started). A Firebase plugin also applies the Gradle file from npm, at the end of that file:apply(from = "../../node_modules/@zeronative/firebase-app/firebase.gradle.kts")(its README). That file is only in@zeronative/firebase-app, which the other Firebase plugins don’t bring on npm, so add it too:bun add --exact @zeronative/firebase-app@0.1.0. - iOS: in Xcode, the plugin’s
ZnPlugin<Name>product of the zero-native package on the app target. The Firebase plugins and Lottie come fromhttps://github.com/zero-native/zero-native-firebaseandhttps://github.com/zero-native/zero-native-lottie, added at the same exact version.
Then register it at startup, as in step 4.
3. Core Plumbing Every Plugin Shares
Section titled “3. Core Plumbing Every Plugin Shares”Common OS primitives are built directly into @zeronative/core:
- Permissions:
Permissions.status(["camera"])andPermissions.request(["location"])(both take arrays of permission names and return a map of"granted" | "denied" | "blocked"). - Opening external apps for a result:
launches(survives Android process death). - Links & sharing:
Linking.openURL(...),Share.share(...). - Clipboard, haptics, vibration, OS info:
Clipboard,Os,Vibration,Platform,Dimensions. - Background JS tasks:
defineTask("my.task", async (data) => ...)runs headless JS in your bundle with a time limit without a screen mounted. (For FCM push messages, usePush.onMessagefrom@zeronative/firebase-messaging, which wires thepush.messagetask automatically.)
4. Writing Your Own Plugin
Section titled “4. Writing Your Own Plugin”A plugin is a package with a zeroNative block in package.json (declaring platforms and android.plugin) and native code on Android and/or iOS (views and screens are registered natively inside register(r)). Module names should start with the package’s first word, and module versions follow add-only versioning (increment version whenever you add a method; never break existing methods).
A. Native Modules (JS ↔ Kotlin / Swift)
Section titled “A. Native Modules (JS ↔ Kotlin / Swift)”Declare a typed proxy handle in TypeScript using nativeModule:
import { nativeModule } from "@zeronative/core"
interface MyPaymentsModule { startUpi(args: { uri: string }): Promise<{ status: string }> events: { statusChanged: { status: string } }}
// The compiler records "MyPayments" version 1 in zn-bundle.json automaticallyexport const MyPayments = nativeModule<MyPaymentsModule>("MyPayments", { version: 1 })
// Call methods directly on the proxy:const res = await MyPayments.startUpi({ uri: "upi://pay?..." })- Android: Subclass
ZnModuleBase("MyPayments", version = 1)and register it from yourZnPlugin’sregister(r)(r.module(...)), then register the plugin inMainApplication.kt. - iOS: Conform to
ZnPlugin, implementregister(_ r: ZnPluginRegistry)callingr.module(...)/r.view(...)/r.screen(...), and register the plugin viaZnPlugins.register(...)inAppDelegate.swift.
B. Native Views (<NativeView>)
Section titled “B. Native Views (<NativeView>)”Plugins can expose custom native views (Compose composables, Android Views, or UIKit/SwiftUI views) via r.view("plugin.viewName", ...) and wrap them in a clean TSX component (for example, @zeronative/scanner wraps <NativeView name="scanner.qr" /> in <QrScanner onScan={...} />):
import { NativeView } from "@zeronative/ui"
<NativeView name="scanner.qr" style={{ width: "100%", height: 300 }} props={{ torch: torchOn() }} onEvent={(e) => { if (e.name === "scanned") handleQr(e.data.value) }}/>namemust be a string literal so the compiler verifies the plugin is installed and records it in the OTA capability manifest. Always give<NativeView>an explicit size instyle.
C. Native Screens (Routes)
Section titled “C. Native Screens (Routes)”Plugins can register full native screens via r.screen("myplugin.picker", ...) and expose them as routes:
export const routes = defineRoutes({ picker: { path: "/picker", native: "myplugin.picker" },})For screens that return a result, use nav.pushForResult(...) / onNavResult(...). (For official plugins with helper APIs — such as ImageViewer.open({ images, imageIndex }) — use the plugin’s API rather than pushing its internal route directly.)