Gathering detailed insights and metrics for react-native-cronet
Gathering detailed insights and metrics for react-native-cronet
Gathering detailed insights and metrics for react-native-cronet
Gathering detailed insights and metrics for react-native-cronet
[Deprecated] This package allows you to use the Cronet for your react native apps.
npm install react-native-cronet
Typescript
Module System
Node Version
NPM Version
Java (44.75%)
JavaScript (14.22%)
TypeScript (13.96%)
Objective-C++ (10.54%)
Objective-C (8.68%)
Ruby (6.61%)
Starlark (0.93%)
C (0.16%)
Swift (0.15%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
138 Stars
16 Commits
17 Forks
8 Watchers
27 Branches
1 Contributors
Updated on Jun 20, 2025
Latest Version
0.5.0
Package Id
react-native-cronet@0.5.0
Unpacked Size
52.83 kB
Size
15.40 kB
File Count
21
NPM Version
6.13.7
Node Version
13.11.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
25
Cronet is the networking stack of Chromium put into a library for use on mobile. This is the same networking stack that is used in the Chrome browser by over a billion people. It offers an easy-to-use, high performance, standards-compliant, and secure way to perform HTTP requests. Cronet has support for both Android and iOS.
This module allows you to use the Cronet stack for your react native apps. Checkout default react-native vs react-native-cronet comparison on android when loading many images on a high lateceny and packetloss network
React Native | react-native-cronet |
---|---|
>=0.62 | 0.5.0 |
>=0.60 | 0.4.0 |
<0.60 | unsupported |
Using npm:
1npm install --save react-native-cronet
or using yarn:
1yarn add react-native-cronet
react-native-cronet
will link automatically using the autolink.
Make sure to run pod install
in your iOS folder to get the Cronet.framework
dependency included.
Libraries
➜ Add Files to [your project's name]
node_modules
➜ react-native-cronet
and add RNCronet.xcodeproj
libRNCronet.a
to your project's Build Phases
➜ Link Binary With Libraries
pod 'Cronet'
as a dependency in your iOS Podfile
and run pod install
, alternatively manaually link Cronet.framework to your projectCmd+R
)<android/app/src/main/java/[...]/MainApplication.java
import com.akshetpandey.rncronet.RNCronetPackage;
to the imports at the top of the filenew RNCronetPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-cronet'
project(':react-native-cronet').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-cronet/android')
android/app/build.gradle
:
compile project(':react-native-cronet')
For iOS, you will have to disable bitcode for your target.
Build Settings
➜ Enable Bitcode
➜ No
For Android, in your MainApplication.java
, you will have to change how RN initializes FrescoModule
by adding these lines:
1import com.akshetpandey.rncronet.RNCronetFrescoImagePipelineConfig; // <--- ADD THIS 2import com.facebook.imagepipeline.core.ImagePipelineConfig; // <--- ADD THIS 3import com.facebook.react.shell.MainPackageConfig; // <--- ADD THIS 4 5public class MainApplication extends Application implements ReactApplication { 6 private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 7 //... 8 @Override 9 protected List<ReactPackage> getPackages() { 10 ImagePipelineConfig pipelineConfig = RNCronetFrescoImagePipelineConfig.build(getApplicationContext()); // <--- ADD THIS 11 MainPackageConfig config = new MainPackageConfig.Builder().setFrescoConfig(pipelineConfig).build(); // <--- ADD THIS 12 List<ReactPackage> packages = new PackageList(this, config).getPackages(); // <--- CHANGE THIS TO INCLUDE CONFIG 13 // Packages that cannot be autolinked yet can be added manually here, for example: 14 return packages; 15 } 16 //... 17 } 18}
Although the library is capable of automatically configuring itself, you can also initialize the cronet engine based on your use case. One reason to do this would be to provide QUIC hints for your domain that you know supports QUIC, or to customize cache size and type.
Make sure this is done before the react native bridge gets initialized.
Nothing needs to be done on the JS side.
Somewhere in your app startup flow, ex. in AppDelegate.m
, you can install an initializer block that can initialize the library for your requirements.
iOS documentation for the cronet library initialization is sparse, but you can look at Cronet/Cronet.h
1#import <RCTCronetHTTPRequestHandler.h> 2#import <Cronet/Cronet.h> 3 4- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 5 // ... 6 7 [RCTCronetHTTPRequestHandler setCustomCronetBuilder:^{ 8 [Cronet setHttp2Enabled:YES]; 9 [Cronet setQuicEnabled:YES]; 10 [Cronet setBrotliEnabled:YES]; 11 [Cronet setHttpCacheType:CRNHttpCacheTypeDisk]; 12 13 [Cronet addQuicHint:@"www.google.com" port:443 altPort:443]; 14 15 [Cronet start]; 16 17 [Cronet registerHttpProtocolHandler]; 18 }]; 19 20 // ... 21}
Somewhere in your app startup flow, ex in MainActivity.java
, you can install an initializer block that can initialize the library for your requirements.
Android documentation for the cronet library initialization is available in CronetEngine.Builder
1import org.chromium.net.CronetEngine; 2 3public class MainActivity extends ReactActivity { 4 @Override 5 protected void onCreate(Bundle savedInstanceState) { 6 // ... 7 RNCronetNetworkingModule.setCustomCronetBuilder(context -> { 8 File cacheDir = new File(context.getCacheDir(), "cronet-cache"); 9 cacheDir.mkdirs(); 10 CronetEngine cronetEngine = new CronetEngine.Builder(context) 11 .enableBrotli(true) 12 .enableHttp2(true) 13 .enableQuic(true) 14 .setStoragePath(cacheDir.getAbsolutePath()) 15 .enableHttpCache(CronetEngine.Builder.HTTP_CACHE_DISK, 10 * 1024 * 1024) 16 .addQuicHint("www.google.com", 443, 443) 17 .build(); 18 URL.setURLStreamHandlerFactory(cronetEngine.createURLStreamHandlerFactory()); 19 return cronetEngine; 20 }); 21 // ... 22 } 23}
No vulnerabilities found.
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
no SAST tool detected
Details
Reason
Found 0/16 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
65 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More