Advanced haptic feedback and vibration control using Pure JSI for React Native
npm install react-native-haptic-engineA unified, high-performance haptic feedback & vibration library for React Native.
Bridge the gap between Androidβs precise Vibrator API and iOSβs Taptic Engine with a single, simple function.
---
- π³ Unified API
One function works seamlessly on both Android and iOS.
- π€ Android Precision
Control exact duration (milliseconds) and intensity (1β255).
- π iOS Taptic Support
Automatically maps vibration strength to Light / Medium / Heavy impact styles.
- β‘ Zero Lag
Pure native implementation for instant feedback.
- π± Expo Compatible
Works with Expo Development Builds (CNG).
- π¦ Zero Dependencies
---
``bash`
npm install react-native-haptic-engine
If you are using React Native CLI, install CocoaPods:
`bash`
cd ios && pod install && cd ..
---
This library includes custom native code and will NOT work in Expo Go.
You must use a Development Build.
1. Install the package:
`bash`
npm install react-native-haptic-engine
2. Rebuild your app:
`bash`
npx expo run:androidor
npx expo run:ios
| Environment | Supported |
|-----------|-----------|
| React Native CLI | β
Yes |
| Expo Dev Client | β
Yes |
| Expo Go | β No |
---
`ts
import { vibrate, stop } from 'react-native-haptic-engine';
// 1. Light Tick (toggle / selection)
// Android: 50ms at low power
// iOS: Light Impact
vibrate(50, 40);
// 2. Normal Tap (button press)
// Android: 100ms at medium power
// iOS: Medium Impact
vibrate(100, 150);
// 3. Heavy Thud (error / explosion)
// Android: 500ms at max power
// iOS: Heavy Impact
vibrate(500, 255);
// 4. Stop vibration (Android only)
stop();
`
---
Triggers a haptic / vibration event.
| Parameter | Type | Default | Description |
|---------|------|---------|-------------|
| milliseconds | number | 400 | Android only. Duration of vibration. Ignored on iOS |
| amplitude | number | 255 | Intensity from 1β255 |
---
| Amplitude Range | Android Behavior | iOS Behavior |
|----------------|-----------------|--------------|
| 1 β 50 | Low intensity vibration | UIImpactFeedbackStyle.Light |
| 51 β 150 | Medium intensity vibration | UIImpactFeedbackStyle.Medium |
| 151 β 255 | High intensity vibration | UIImpactFeedbackStyle.Heavy |
---
Stops any ongoing vibration.
| Platform | Behavior |
|--------|----------|
| Android | Stops vibration immediately |
| iOS | No-op (impact haptics are instantaneous) |
---
Cause:
Running the app in Expo Go.
Fix:
Build a development client:
`bash`
npx expo run:androidor
npx expo run:ios
---
- Ensure the device is not in Silent / Do Not Disturb mode
- Some OEMs disable vibration in silent mode
- No manual permissions needed
The library automatically adds:
`xml``
---
MIT
---
Author: Vasanth S