Haptics
このコンテンツはまだ日本語訳がありません。
Haptic feedback and vibrations on Android and iOS.
There are no standards/requirements for vibration support on Android, so the feedback APIs may not work correctly on more affordable phones, including recently released ones.
This plugin requires a Rust version of at least 1.77.2
| Platform | Level | Notes |
|---|---|---|
| windows | | |
| linux | | |
| macos | | |
| android | ||
| ios |
Install the haptics plugin to get started.
Use your project’s package manager to add the dependency:
npm run tauri add hapticsyarn run tauri add hapticspnpm tauri add hapticsdeno task tauri add hapticsbun tauri add hapticscargo tauri add haptics-
Run the following command in the
src-taurifolder to add the plugin to the project’s dependencies inCargo.toml:cargo add tauri-plugin-haptics --target 'cfg(any(target_os = "android", target_os = "ios"))' -
Modify
lib.rsto initialize the plugin:src-tauri/src/lib.rs #[cfg_attr(mobile, tauri::mobile_entry_point)]pub fn run() {tauri::Builder::default().setup(|app| {#[cfg(mobile)]app.handle().plugin(tauri_plugin_haptics::init());Ok(())}).run(tauri::generate_context!()).expect("error while running tauri application");} -
Install the JavaScript Guest bindings using your preferred JavaScript package manager:
npm install @tauri-apps/plugin-hapticsyarn add @tauri-apps/plugin-hapticspnpm add @tauri-apps/plugin-hapticsdeno add npm:@tauri-apps/plugin-hapticsbun add @tauri-apps/plugin-haptics
The haptics plugin is available in JavaScript.
import { vibrate, impactFeedback, notificationFeedback, selectionFeedback,} from '@tauri-apps/plugin-haptics';
await vibrate(1);await impactFeedback('medium');await notificationFeedback('warning');await selectionFeedback();By default all potentially dangerous plugin commands and scopes are blocked and cannot be accessed. You must modify the permissions in your capabilities configuration to enable these.
See the Capabilities Overview for more information and the step by step guide to use plugin permissions.
{ "$schema": "../gen/schemas/mobile-schema.json", "identifier": "mobile-capability", "windows": ["main"], "platforms": ["iOS", "android"], "permissions": [ "haptics:allow-impact-feedback", "haptics:allow-notification-feedback", "haptics:allow-selection-feedback", "haptics:allow-vibrate" ]}Permission Table
| Identifier | Description |
|---|---|
|
|
Enables the impact_feedback command without any pre-configured scope. |
|
|
Denies the impact_feedback command without any pre-configured scope. |
|
|
Enables the notification_feedback command without any pre-configured scope. |
|
|
Denies the notification_feedback command without any pre-configured scope. |
|
|
Enables the selection_feedback command without any pre-configured scope. |
|
|
Denies the selection_feedback command without any pre-configured scope. |
|
|
Enables the vibrate command without any pre-configured scope. |
|
|
Denies the vibrate command without any pre-configured scope. |
© 2025 Tauri Contributors. CC-BY / MIT