Skip to content

docs/feat: improve manual MainApplication setup docs and explore autolinking hooks #19

Description

@imsankalp

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

  • SETUP_GUIDE.md has a full before/after diff for Kotlin and Java MainApplication
  • BuildConfig.DEBUG guard documented and explained in setup guide
  • Troubleshooting section added covering the 3 most common setup mistakes
  • Autolinking hook options evaluated — decision documented in ARCHITECTURE.md
  • Runtime warning implemented when interceptor appears unregistered in dev mode
  • README quick-start section reflects the updated setup steps

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions