The Vibration API provides access to the device’s vibration functionality. You can trigger single vibrations or pattern-based vibrations.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/facebook/react-native/llms.txt
Use this file to discover all available pages before exploring further.
Methods
vibrate()
Vibration pattern:
- number: Duration in milliseconds to vibrate
- array: Pattern of durations alternating between vibrate and pause
- Example:
[0, 500, 200, 500]means:- Wait 0ms
- Vibrate 500ms
- Pause 200ms
- Vibrate 500ms
- Example:
Whether to repeat the vibration pattern. Only applies when pattern is an array.Android: Repeats from the first vibration (index 0)iOS: Repeats the entire pattern
Platform Differences
Android
- Supports both single vibrations and pattern arrays
- Pattern arrays are passed directly to the native module
- Repeat behavior starts from index 0
- Requires
VIBRATEpermission inAndroidManifest.xml:
iOS
- Supports single vibrations and pattern arrays
- Pattern arrays are processed in JavaScript with scheduling
- Default vibration duration is 400ms regardless of the number passed
- No permissions required
cancel()
Examples
Single Vibration
Default Vibration
Pattern Vibration
Repeating Pattern
Custom Alert Pattern
SOS Pattern
Notes
- On iOS, the vibration duration cannot be customized; the device will always vibrate for approximately 400ms
- Android allows custom duration vibrations
- Always call
cancel()when stopping a repeating vibration pattern - Excessive vibration can drain battery and annoy users - use judiciously
- Test vibration patterns on physical devices as simulators/emulators may not support vibration