{"id":17340,"library":"react-native-network-logger","title":"React Native Network Logger","description":"`react-native-network-logger` is an HTTP traffic monitoring library designed for React Native applications. It provides an intuitive in-app user interface to visualize and debug network requests on both iOS and Android platforms, including in production/release builds. The current stable version is 2.0.1, with a consistent release cadence that has seen multiple updates in 2024 and 2025, indicating active maintenance and ongoing development. A key differentiator of this library is its complete absence of native dependencies, simplifying integration significantly compared to other tools. It allows developers to inspect detailed request and response headers and bodies, copy specific data, share cURL representations of requests, and export all captured logs in HAR (HTTP Archive) format. Built with TypeScript, it also supports advanced features like GraphQL operation name extraction and custom theming, providing a comprehensive and zero-configuration solution for network debugging.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/alexbrazier/react-native-network-logger","tags":["javascript","react","native","react-native","network","interceptor","http","monitor","logging","typescript"],"install":[{"cmd":"npm install react-native-network-logger","lang":"bash","label":"npm"},{"cmd":"yarn add react-native-network-logger","lang":"bash","label":"yarn"},{"cmd":"pnpm add react-native-network-logger","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for using the React components provided by the library.","package":"react","optional":false},{"reason":"Peer dependency required for integrating the library within a React Native application environment.","package":"react-native","optional":false}],"imports":[{"note":"This function should be called as early as possible in your app's entry point (e.g., `index.js` or `App.js`) to ensure all network requests are intercepted.","wrong":"const startNetworkLogging = require('react-native-network-logger').startNetworkLogging;","symbol":"startNetworkLogging","correct":"import { startNetworkLogging } from 'react-native-network-logger';"},{"note":"The `NetworkLogger` component is a default export and should be imported without curly braces. It provides the UI to display intercepted network traffic.","wrong":"import { NetworkLogger } from 'react-native-network-logger';","symbol":"NetworkLogger","correct":"import NetworkLogger from 'react-native-network-logger';"},{"note":"This is a TypeScript type definition. Use `import type` to avoid bundling unused code in environments that support it, or a standard `import` if your setup doesn't differentiate.","wrong":"import { NetworkLoggerProps } from 'react-native-network-logger';","symbol":"NetworkLoggerProps","correct":"import type { NetworkLoggerProps } from 'react-native-network-logger';"}],"quickstart":{"code":"import { startNetworkLogging } from 'react-native-network-logger';\nimport NetworkLogger from 'react-native-network-logger';\nimport React, { useEffect, useState } from 'react';\nimport { View, Button, Modal, Text, StyleSheet } from 'react-native';\n\n// Start logging as early as possible in your app's entry point.\n// For demonstration, it's shown here, but typically placed in index.js or App.js.\nstartNetworkLogging({\n  maxRequests: 500, // Retain a maximum of 500 requests\n  // Example: ignore specific URLs or patterns\n  ignoredUrls: [/^https:\\/\\/example\\.com\\/health/, /localhost\\:\\d+\\/__/],\n});\n\nconst App = () => {\n  const [isVisible, setIsVisible] = useState(false);\n\n  useEffect(() => {\n    // In a real app, you might trigger the logger visibility via a debug menu\n    // or a specific gesture in development builds.\n  }, []);\n\n  return (\n    <View style={styles.container}>\n      <Text style={styles.title}>React Native Network Logger Demo</Text>\n      <Button title=\"Show Network Logger\" onPress={() => setIsVisible(true)} />\n      <Modal\n        animationType=\"slide\"\n        transparent={false}\n        visible={isVisible}\n        onRequestClose={() => setIsVisible(false)}\n      >\n        <NetworkLogger\n          theme=\"dark\" // Optional: specify 'dark' or 'light'\n          // Or provide a custom theme object: { backgroundColor: '#222', textColor: '#eee', ... }\n        />\n        <Button title=\"Close Logger\" onPress={() => setIsVisible(false)} />\n      </Modal>\n    </View>\n  );\n};\n\nconst styles = StyleSheet.create({\n  container: {\n    flex: 1,\n    justifyContent: 'center',\n    alignItems: 'center',\n    backgroundColor: '#F5FCFF',\n  },\n  title: {\n    fontSize: 20,\n    textAlign: 'center',\n    margin: 10,\n  },\n});\n\nexport default App;\n","lang":"typescript","description":"This code demonstrates how to initialize `react-native-network-logger` to start intercepting HTTP requests and then render the `<NetworkLogger />` component within a modal to display the intercepted traffic. It includes basic styling and options for `startNetworkLogging` like `maxRequests` and `ignoredUrls`."},"warnings":[{"fix":"Review your project's import paths and module resolution settings. Ensure your build environment is compatible with modern React Native module formats. Update your `import` statements according to the new export structure (e.g., `NetworkLogger` is a default export).","message":"Version 2.0.0 introduced breaking changes related to the package's build format and exports, which might require updates to import statements or custom Metro/Babel configurations in your React Native project.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure you are using the latest `react-native-network-logger` version compatible with your React Native version. Version 2.0.0 provides a fallback for `XHRInterceptor` import paths, while 2.0.1 specifically resolves issues for React Native 0.80+.","message":"The internal `XHRInterceptor`'s location changed in v2.0.0 and v2.0.1 to accommodate updates in React Native versions 0.79+ and 0.80+. Failure to update the package may result in network logging not functioning correctly or silent failures, particularly for projects on newer React Native versions.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Thoroughly test any custom theme implementations after upgrading `react-native-network-logger`. For more stable theming, consider using the built-in `dark` or `light` string options.","message":"Custom theme objects provided to the `NetworkLogger` component are not guaranteed to maintain backward compatibility across minor or major version updates of the library, potentially requiring adjustments after upgrading.","severity":"gotcha","affected_versions":">=1.12.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Update `react-native-network-logger` to version 2.0.0 or newer. Specifically, version 2.0.1 addresses compatibility issues with React Native 0.80.","cause":"The `react-native-network-logger` library failed to correctly locate and patch the global `XMLHttpRequest` object due to changes in React Native's internal structure in versions 0.79 or 0.80.","error":"Error: XHRInterceptor location for RN 80"},{"fix":"Change the import statement from `import { NetworkLogger } from 'react-native-network-logger';` to `import NetworkLogger from 'react-native-network-logger';`.","cause":"Attempting to import `NetworkLogger` as a named export (`{ NetworkLogger }`) when it is a default export of the package.","error":"TS2305: Module '\"react-native-network-logger\"' has no exported member 'NetworkLogger'. Did you mean to use 'import NetworkLogger from \"react-native-network-logger\"' instead?"},{"fix":"Ensure `react-native-network-logger` is updated to a version compatible with your `react-native` version (e.g., v2.0.1 for RN 0.80). Clear your Metro bundler cache (`npm start -- --reset-cache`) and reinstall node modules (`rm -rf node_modules && npm install`).","cause":"The internal `XHRInterceptor` could not be found or correctly imported by `react-native-network-logger`, often due to `react-native` version incompatibilities or Metro bundler caching issues.","error":"ReferenceError: Can't find variable: XHRInterceptor"},{"fix":"Use a type-only import: `import type { NetworkLoggerProps } from 'react-native-network-logger';`.","cause":"Attempting to import the `NetworkLoggerProps` type as a value import (`import { NetworkLoggerProps } from ...`) rather than a type-only import.","error":"TS2305: Module '\"react-native-network-logger\"' has no exported member 'NetworkLoggerProps'."}],"ecosystem":"npm","meta_description":null}