react-native-smart-review
v0.1.0
Published
Tiny React Native hook for asking the user to rate your app and redirecting to the store when appropriate.
Maintainers
Readme
react-native-smart-review
A tiny React Native / Expo hook that presents a friendly in-app rating modal and triggers the native in-app review dialogs (with a store fallback) when the user leaves a high enough rating.
Installation
npm install react-native-smart-review
# or
yarn add react-native-smart-reviewThe native modules required for the App Store / Play Store dialogs ship with this package.
- iOS: run
npx pod-installafter installing the package. - Android: rebuild your app so Gradle picks up the new module.
- Expo: supported in managed and bare workflows. In managed apps run
expo prebuild(or build/custom dev client via EAS) after installing so the native code is compiled into your bundle.
Usage
import { Button } from 'react-native';
import { useBetterAppReview } from 'react-native-smart-review';
export function HomeScreen() {
const { openReview, ReviewModal } = useBetterAppReview({
iosAppId: '1234567890',
androidPackageName: 'com.example.app',
minStarsToRedirect: 4,
reviewDoneMessage: 'Thanks for letting us know!',
});
return (
<>
<ReviewModal />
<Button title="Rate the app" onPress={openReview} />
</>
);
}API
iosAppId: Required on iOS. The numeric App Store identifier.androidPackageName: Required on Android. Your Play Store package name.minStarsToRedirect: (default4) Minimum star rating that triggers the in-app review flow.reviewDoneMessage: Optional message shown if the user submits a rating below the threshold.reviewTitle,reviewBody: Copy overrides inside the modal.submitButtonLabel,cancelButtonLabel: Button overrides.redirectErrorTitle,redirectErrorMessage: Shown when the store fallback cannot be opened.onReviewFinished: Callback invoked after the flow completes. Receives{ rating, redirected, error }.
The hook returns:
openReview: Function to show the modal.ReviewModal: Render this component near the root so the modal can mount.isVisible: Modal visibility flag.dismiss: Imperative dismiss helper.
How it works
- Call
openReview()to show the modal. - The user picks a rating from 1 to 5.
- Ratings equal to or above
minStarsToRedirectfirst try to launch the native in-app review dialog. If that isn't available (for example on simulators or unsupported OS versions), the hook falls back to opening the store listing. If both attempts fail, a friendly alert is shown instead. - Lower ratings close the modal and show
reviewDoneMessage(if provided).
License
MIT License
