React Native Network Logger

2.0.1 · active · verified Wed Apr 22

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

Common errors

Warnings

Install

Imports

Quickstart

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;

view raw JSON →