Problem
Non-Expo users on bare React Native must manually edit MainApplication.kt / MainApplication.java to add the OkHttp client builder — a native code change that is error-prone, easy to forget, and not validated at install time. There is no autolinking hook that handles this automatically for bare RN.
Current setup docs are brief and lack:
Proposed improvements
1. Expand SETUP_GUIDE.md with a step-by-step native setup section
Include:
- Full before/after diff for both Kotlin and Java
MainApplication
- Explanation of
NetworkingModule.setCustomClientBuilder and why it must be called before loadReactNative
- The
BuildConfig.DEBUG guard with rationale
- Common errors and how to fix them (e.g.
ClassNotFoundException, interceptor not capturing requests)
2. Explore React Native autolinking hooks
React Native's autolinking system supports postInstall hooks in react-native.config.js or package-level scripts. Investigate whether we can auto-patch MainApplication for bare RN apps on npm install / pod install — similar to what the Expo config plugin does for Expo.
Options to evaluate:
@react-native-community/cli hooks
- A
postinstall script that detects bare RN and applies the same regex patch as plugin/src/index.js
- A dedicated
npx react-native-network-tools setup CLI command
3. Add setup validation
A helper that warns at runtime if the interceptor was not registered:
// In NetworkMonitorProvider's useEffect
if (isNativeNetworkToolsAvailable() && getRequestCount() === 0 && __DEV__) {
console.warn(
'[NetworkTools] No requests captured yet. Did you call ' +
'NetworkingModule.setCustomClientBuilder() in MainApplication?'
);
}
Acceptance criteria
Problem
Non-Expo users on bare React Native must manually edit
MainApplication.kt/MainApplication.javato add the OkHttp client builder — a native code change that is error-prone, easy to forget, and not validated at install time. There is no autolinking hook that handles this automatically for bare RN.Current setup docs are brief and lack:
MainApplicationonCreate()and not elsewhereBuildConfig.DEBUGguard (which is also a separate bug — see bug(android): NETWORK_TOOLS_ENABLED is always true — interceptor runs in production builds #14)Proposed improvements
1. Expand
SETUP_GUIDE.mdwith a step-by-step native setup sectionInclude:
MainApplicationNetworkingModule.setCustomClientBuilderand why it must be called beforeloadReactNativeBuildConfig.DEBUGguard with rationaleClassNotFoundException, interceptor not capturing requests)2. Explore React Native autolinking hooks
React Native's autolinking system supports
postInstallhooks inreact-native.config.jsor package-levelscripts. Investigate whether we can auto-patchMainApplicationfor bare RN apps onnpm install/pod install— similar to what the Expo config plugin does for Expo.Options to evaluate:
@react-native-community/clihookspostinstallscript that detects bare RN and applies the same regex patch asplugin/src/index.jsnpx react-native-network-tools setupCLI command3. Add setup validation
A helper that warns at runtime if the interceptor was not registered:
Acceptance criteria
SETUP_GUIDE.mdhas a full before/after diff for Kotlin and JavaMainApplicationBuildConfig.DEBUGguard documented and explained in setup guideARCHITECTURE.md