
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
react-native-ota-hot-update
Advanced tools
This React Native module allows you to manage hot updates (in-app update) with minimal configuration, similar to Code Push. You can control versioning and host the JS bundle yourself. The library handles the installation of updates after the bundle is downloaded from your server or Git repository. With Code Push retiring soon, this library gives you full control over your update process, whether hosting the bundle on your own server or in a Git repository.
iOS GIF | Android GIF |
---|---|
![]() | ![]() |
iOS GIF | Android GIF |
---|---|
![]() | ![]() |
New architecture backward compatibility supported from version 2, it also supported old architecture, for source code of version 1.x.x please refer to branch oldArch
, you might need install version 1.x.x if you are using react native < 0.70
if you don't want to manage the download progress, need to install blob util together:
yarn add react-native-ota-hot-update && yarn add react-native-blob-util
Auto linking already, need pod install for ios:
cd ios && pod install
Modify app.json
:
"plugins": [
"react-native-ota-hot-update",
...
]
Open AppDelegate.m
and add this:
#import "OtaHotUpdate.h"
...
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [OtaHotUpdate getBundle]; ## add this line
#endif
}
From react native 0.77, AppDelegate changed to swift file, so the configuration will be change a bit.
Open AppDelegate.swift:
import react_native_ota_hot_update
...
override func bundleURL() -> URL? {
#if DEBUG
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
OtaHotUpdate.getBundle() // -> Add this line
#endif
}
AppDelegate.h:
@property (nonatomic, assign) UIBackgroundTaskIdentifier taskIdentifier;
AppDelegate.mm:
- (void)applicationWillResignActive:(UIApplication *)application {
if (self.taskIdentifier != UIBackgroundTaskInvalid) {
[application endBackgroundTask:self.taskIdentifier];
self.taskIdentifier = UIBackgroundTaskInvalid;
}
__weak AppDelegate *weakSelf = self;
self.taskIdentifier = [application beginBackgroundTaskWithName:nil expirationHandler:^{
if (weakSelf) {
[application endBackgroundTask:weakSelf.taskIdentifier];
weakSelf.taskIdentifier = UIBackgroundTaskInvalid;
}
}];
}
AppDelegate.swift(RN >= 0.77):
class AppDelegate: RCTAppDelegate {
var taskIdentifier: UIBackgroundTaskIdentifier = .invalid
...
override func applicationWillResignActive(_ application: UIApplication) {
// End any existing background task
if taskIdentifier != .invalid {
application.endBackgroundTask(taskIdentifier)
taskIdentifier = .invalid
}
// Start a new background task
taskIdentifier = application.beginBackgroundTask(withName: nil) { [weak self] in
if let strongSelf = self {
application.endBackgroundTask(strongSelf.taskIdentifier)
strongSelf.taskIdentifier = .invalid
}
}
}
Open MainApplication.kt
and add these codes bellow:
import com.otahotupdate.OtaHotUpdate
...
override fun getJSBundleFile(): String? {
return OtaHotUpdate.bundleJS(this@MainApplication)
}
MainApplication.java:
@Nullable
@Override
protected String getJSBundleFile() {
return OtaHotUpdate.getBundleJS(this);
}
For java it maybe can be like: OtaHotUpdate.Companion.getBundleJS(this)
depend on kotlin / jdk version on your project, you can use android studio to get the correct format coding.
If want to remove bundle wrong handler, pass false param in getBundleJS like this:
return OtaHotUpdate.bundleJS(this@MainApplication, false)
Open AndroidManifest.xml
:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application ... android:requestLegacyExternalStorage="true"
Remember hot update just work at release mode, debug mode won't working
With this method, you can host the bundle JS on your own server. The app fetches the updates directly from the server, allowing for dynamic updates.
For detailed instructions on how to implement this, refer to DOC_OTA_SERVER.md.
This method allows you to use a Git repository to host the bundle JS. The app pulls updates directly from the repository, providing an easy and version-controlled way to manage updates.
For detailed instructions on how to implement this, refer to DOC_OTA_GIT.md.
Using Strapi, you can build a tailored admin panel to manage React Native hot updates effectively. This approach allows you to centralize the control of versioning and OTA updates while providing a user-friendly interface for managing content. To get started, refer to the detailed steps and code examples in this guide. For additional details, see OTA_CMS.md.
FAQs
Hot update for react native
The npm package react-native-ota-hot-update receives a total of 1,350 weekly downloads. As such, react-native-ota-hot-update popularity was classified as popular.
We found that react-native-ota-hot-update demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.