Skip to content

Native Plugins

Add native features such as haptics, Face ID, and notifications to your app from mobile.toml, without writing Swift or Kotlin.

Introduction

Native features like haptics, Face ID, and notifications are provided by Tauri v2 plugins. Adding one to your app doesn’t require any Swift, Kotlin, or JSON; you simply enable it in the plugins section of your mobile.toml file:

mobile.tomltoml
[plugins]
haptics = true
biometric = true

[permissions]
biometrics = "Unlock Acme with Face ID & Touch ID."

The next time you run laravel-mobile sync, or dev or build, the plugin’s crate is added to apps/mobile/Cargo.toml, registered in src/plugins.rs, and granted its default permissions.

For the paid features, you may skip the edit. laravel-mobile install <feature> adds the [plugins] line for you and runs sync, so you only add the permission text yourself.

Available Plugins

The following official plugins are available today:

Plugin Provides
barcode-scanner QR and barcode scanning.
biometric Face ID, Touch ID, and fingerprint prompts.
clipboard-manager Reading and writing the clipboard.
deep-link Handling deep links.
dialog Native alert, confirm, and file dialogs.
geolocation The device’s location.
haptics Vibration and haptic feedback.
notification Local notifications. For remote push through APNs or Firebase, see Push Notifications.
opener Opening links and files in other apps.
os Information about the device’s operating system.
store A persistent key-value store.

The configuration documentation describes each of them in detail. To call them from your pages, use the JavaScript adapter.

Plugin Permissions

Some plugins, such as biometric, barcode-scanner, geolocation, and notification, need a matching entry in the permissions section. Each permission’s text is the sentence iOS shows your users when it asks, so you should explain plainly why your app needs it:

mobile.tomltoml
[permissions]
camera = "Scan receipts to attach them to expenses."

If you forget a permission, don’t worry. The config check command will tell you exactly which one is missing:

laravel-mobile config check

Using the Camera

You don’t need a plugin to take a photo. In a release build, your pages load from a secure origin inside the app, so the web platform’s camera features work as they do in a mobile browser. A file input with the capture attribute opens the phone’s camera:

<input type="file" accept="image/*" capture="environment" />

For a live preview, such as a custom scanner view, you may use navigator.mediaDevices.getUserMedia instead. It works in release builds, but not in dev, because dev loads your pages over plain http://. See running your app for details.

Either way, add a camera entry to the permissions section. On iOS, its text is the prompt your users see. On Android, laravel-mobile sync also declares the camera intents the app needs; without them, Android 11 and later open the photo picker instead of the camera.

The Native Tab Bar

Every app has a native tab bar on iOS and Android, which you define with [[tabs]] in your mobile.toml file. The tab bar shows only on pages under a tab’s path, so it stays hidden on pages such as the login page. Tapping the current tab reloads it, and on Android it hides while the keyboard is open.

To start with a tab bar, run laravel-mobile install tabs. It adds a Home tab at /dashboard and a Settings tab at /settings, and you point each tab’s path at a page your app has.

Premium Plugins

Four paid plugins add features that the free plugins don’t cover. The paid plans, Starter and Pro, include all four. The free plan includes none of them. Biometric login and secure storage are in alpha, and offline and SQLite are in beta. Try them in a test app first, and expect their settings to change before they are stable.

Plugin Provides Stage
biometric-login Signs people back in with Face ID, Touch ID, or a fingerprint. Alpha
secure-storage Keeps tokens and secrets in the iOS Keychain and the Android Keystore. Alpha
offline Holds requests made offline on the phone, and sends them once it’s back online. Beta
sqlite A local SQLite database, with migrations. Beta

To use one, sign in with your cloud account, then enable the plugin:

laravel-mobile login
laravel-mobile install offline

The install command turns the plugin on in mobile.toml, and sync writes the plugin’s registry into your app’s .cargo/config.toml. Your sign-in gives your machine the token Cargo needs. Then run dev or build as usual. In CI, set LRM_CLOUD_TOKEN to an API token from your dashboard instead of signing in.

Biometric login needs a fingerprint or a face enrolled on the phone, so a phone with only a PIN can’t use it. Show the option only when available() on mobile.biometricLogin returns true.

Offline Requests

The offline plugin holds the requests your pages make while the phone is offline, and sends them once it’s back online. A request whose response was lost may be sent twice, so your server should run it once. Add the free idempotent middleware to the web group in src/app.rs:

.with_middleware(|middleware, _| {
    middleware.web(|web| {
        web.append(laravel_mobile::idempotent);
    });
})

The first successful response to a POST, PUT, PATCH, or DELETE request that carries an Idempotency-Key header is kept for 24 hours. A retry with the same key gets that response back, with an Idempotent-Replayed: true header, instead of running your handler again. A retry that arrives while the first attempt is still running gets a 409, which the offline plugin retries later. Error responses are not kept, so a retry runs again. laravel-mobile install offline prints this line as a next step.

Turnkey premium plugins, such as in-app purchases with RevenueCat, Apple Pay and Google Pay, and background geolocation, are planned for the paid plans after v0.1.

Writing Your Own Plugins

When the built-in plugins don’t cover what you need, you may write your own Tauri plugin with Swift and Kotlin. Custom native code requires Xcode or Android Studio on your machine.

Type to search…

↑↓ navigate↵ selectEsc close