react-native-simple-updater
v1.0.11
Published
A lightweight and customizable React Native update checker for Android apps. Supports automatic version checking, APK downloading, and installing — with support for Android 13+ install permissions and MMKV caching to prevent repeated downloads.
Readme
react-native-simple-updater
A lightweight and customizable React Native update checker for Android apps. Supports automatic version checking, APK downloading, and installing — with support for Android 13+ install permissions and MMKV caching to prevent repeated downloads.
Features
- ✅ Auto or manual update checks
- ✅ APK download with progress UI
- ✅ MMKV caching to avoid repeated downloads
- ✅ Resume install if previously downloaded
- ✅ Android 13+ install permission support
- ✅ Fully customizable trigger button
Installation
Install the library and required dependencies:
yarn add react-native-simple-updaterPeer Dependencies
yarn add react-native-mmkv react-native-device-info react-native-fs rn-fetch-blob axiosAlso, ensure these are properly linked (if using older React Native versions).
API Response Format
Your updateUrl must return a JSON response structured like:
{
"data": {
"version": "1.0.5",
"apkSignedUrl": "https://cdn.yourdomain.com/releases/app-release.apk"
}
}How It Works
- When the app loads, it optionally checks a remote endpoint (
updateUrl) for version info. - It compares the
versionfrom the response with the current app version usingreact-native-device-info. - If a newer version is found:
- It either downloads the APK automatically (
autoDownload: true) - Or shows a customizable “Update Now” button (
autoDownload: false)
- It either downloads the APK automatically (
- Once downloaded, the APK is saved to the Downloads folder.
- If the install was not completed, the next app open will prompt to install.
- For Android 13+, the library checks and prompts for permission to install unknown apps if not already granted.
Usage
Simple Usage with Auto Check & Manual Download
import { UpdateChecker } from 'react-native-simple-updater';
export default function App() {
return (
<>
<UpdateChecker
updateUrl="https://api.yourserver.com/apps/myapp/latest"
autoCheck={true}
autoDownload={false}
/>
<MainApp />
</>
);
}Auto Download on Detection
<UpdateChecker
updateUrl="https://api.yourserver.com/apps/myapp/latest"
autoCheck={true}
autoDownload={true}
/>Props
| Prop | Type | Default | Description |
|--------------------|-------------|-------------|-----------------------------------------------------------------------------|
| updateUrl | string | — | Required. URL that returns latest version and APK URL. |
| autoCheck | boolean | true | Automatically check for updates when component mounts.
🔁 Manual Hook Usage
Use the internal hook if you want full control:
import { useUpdateChecker } from 'react-native-simple-updater';
const {
updateAvailable,
progress,
installPending,
triggerUpdate,
triggerInstall,
} = useUpdateChecker({
updateUrl: 'https://your-server.com/apps/latest',
autoCheck: true,
autoDownload: false,
});Android Permissions
For Android 13+, installation of APKs requires runtime permission for unknown sources.
Ensure this is added to your AndroidManifest.xml:
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />The library automatically prompts the user if the permission is missing.
📂 File Structure (Overview)
react-native-simple-updater/
├── src/
│ ├── useUpdateChecker.js # Hook logic
│ └── UpdatePrompt.js # UI wrapper
├── index.js
└── README.mdExample Output States
- Update Available → Show button or auto download
- Downloading... → Show progress
- Install Pending → Show “Install Now” if not yet installed
- No update → Renders nothing
Tips
- Use
MMKVto persist the last downloaded version and avoid re-downloading on every boot. installPendingwill be true if the user didn’t install the last downloaded APK.- You can show an “Install” button on next app start if needed.
License
MIT © 2025
FAQ
Will this install updates silently?
❌ No. Android does not allow silent APK installs unless the app is a system app. This library prompts the user using the system installer.
Is this library for Android only?
✅ Yes. iOS support is not included. You may redirect iOS users to the App Store manually.
Contributing
Want to improve this library?
- Fork it
- Submit pull requests
- Report issues
- Share with others 🚀
Contact
For questions or suggestions, open an issue or contact Mushud on GitHub.
