Registry / http-networking / react-native-network-logger

react-native-network-logger

JSON →
library2.0.1jsnpmunverified

`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.

npm install react-native-network-logger
INSTALL
IMPORT
SIG · REACT-NATIVE-NETWO
R
react-native-network-logger
http-networkingjavascriptv2.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

startNetworkLogging
import { startNetworkLogging } from 'react-native-network-logger';
const startNetworkLogging = require('react-native-network-logger').startNetworkLogging;
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.
NetworkLogger
import NetworkLogger from 'react-native-network-logger';
import { NetworkLogger } from 'react-native-network-logger';
The `NetworkLogger` component is a default export and should be imported without curly braces. It provides the UI to display intercepted network traffic.
NetworkLoggerProps
import type { NetworkLoggerProps } from 'react-native-network-logger';
import { NetworkLoggerProps } from 'react-native-network-logger';
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.

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`.

import { startNetworkLogging } from 'react-native-network-logger'; import NetworkLogger from 'react-native-network-logger'; import React, { useEffect, useState } from 'react'; import { View, Button, Modal, Text, StyleSheet } from 'react-native'; // Start logging as early as possible in your app's entry point. // For demonstration, it's shown here, but typically placed in index.js or App.js. startNetworkLogging({ maxRequests: 500, // Retain a maximum of 500 requests // Example: ignore specific URLs or patterns ignoredUrls: [/^https:\/\/example\.com\/health/, /localhost\:\d+\/__/], }); const App = () => { const [isVisible, setIsVisible] = useState(false); useEffect(() => { // In a real app, you might trigger the logger visibility via a debug menu // or a specific gesture in development builds. }, []); return ( <View style={styles.container}> <Text style={styles.title}>React Native Network Logger Demo</Text> <Button title="Show Network Logger" onPress={() => setIsVisible(true)} /> <Modal animationType="slide" transparent={false} visible={isVisible} onRequestClose={() => setIsVisible(false)} > <NetworkLogger theme="dark" // Optional: specify 'dark' or 'light' // Or provide a custom theme object: { backgroundColor: '#222', textColor: '#eee', ... } /> <Button title="Close Logger" onPress={() => setIsVisible(false)} /> </Modal> </View> ); }; const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, title: { fontSize: 20, textAlign: 'center', margin: 10, }, }); export default App;
Debug
Known issues
breakingVersion 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.
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).
affects: >=2.0.0
breakingThe 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.
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+.
affects: >=2.0.0
gotchaCustom 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.
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.
affects: >=1.12.0
Errors
Common errors & fixes
Error: XHRInterceptor location for RN 80
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.
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.
TS2305: Module '"react-native-network-logger"' has no exported member 'NetworkLogger'. Did you mean to use 'import NetworkLogger from "react-native-network-logger"' instead?
Attempting to import `NetworkLogger` as a named export (`{ NetworkLogger }`) when it is a default export of the package.
fix
Change the import statement from `import { NetworkLogger } from 'react-native-network-logger';` to `import NetworkLogger from 'react-native-network-logger';`.
ReferenceError: Can't find variable: XHRInterceptor
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.
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`).
TS2305: Module '"react-native-network-logger"' has no exported member 'NetworkLoggerProps'.
Attempting to import the `NetworkLoggerProps` type as a value import (`import { NetworkLoggerProps } from ...`) rather than a type-only import.
fix
Use a type-only import: `import type { NetworkLoggerProps } from 'react-native-network-logger';`.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
reactrequiredPeer dependency required for using the React components provided by the library.
react-nativerequiredPeer dependency required for integrating the library within a React Native application environment.
Agent activity
28 hits · last 30 days
node
24
OpenAI (training)
2
Resources
react-native-network-logger — npm install react-native-network-logger · libregistry