React Native Shake
Getting Started
Install react-native-shake and wire up your first shake listener.
Install
npm install react-native-shake
# or
yarn add react-native-shakeiOS setup
Run pod install after installing the package:
cd ios && pod installAndroid setup
No additional configuration required - the library links automatically via autolinking (React Native 0.60+).
First listener
import React from 'react';
import RNShake from 'react-native-shake';
export const MyComponent = () => {
React.useEffect(() => {
const subscription = RNShake.addListener(() => {
// Your shake handler here...
});
return () => {
subscription.remove();
};
}, []);
return null;
};addListener returns an EmitterSubscription - call .remove() on unmount to avoid leaking listeners.
The library works out of the box on both the New Architecture (Turbo Modules) and the old/legacy architecture - no extra flags or setup needed either way.
Test on a real device - shake detection is unreliable in simulators/emulators since it relies on actual accelerometer input.