Installation
Install @mhpdev/react-native-haptics in a bare React Native or Expo project.
Bare React Native
Install the package using either npm or Yarn:
npm install @mhpdev/react-native-hapticsOr with Yarn:
yarn add @mhpdev/react-native-hapticsFor iOS, navigate to the ios directory and install the pods:
cd ios && pod installExpo
For Expo projects, follow these steps:
-
Install the package:
npx expo install @mhpdev/react-native-haptics -
Since it is not supported on Expo Go, run:
npx expo prebuild
The library uses Turbo Modules, so it requires the New Architecture. React Native 0.76 and higher have it enabled by default; on React Native 0.68–0.75 you need to enable it first. See the React Native New Architecture guide.
Android requirements
The library's Android module defaults are set in the package's
android/gradle.properties and can be overridden from your project:
| Property | Default |
|---|---|
Haptics_minSdkVersion | 21 |
Haptics_targetSdkVersion | 35 |
Haptics_compileSdkVersion | 35 |
Haptics_kotlinVersion | 2.0.21 |
Haptics_ndkVersion | 27.1.12297006 |
Individual androidHaptics effects have higher Android API requirements —
see Android-specific effects.