npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@modhamanish/rn-network-logger

v1.0.5

Published

A React Native Network Logger component for debugging network requests and responses.

Readme

@modhamanish/rn-network-logger

A premium, lightweight React Native Network Inspector that intercepts and logs network requests/responses in development mode and streams them via WebSockets to a web browser-based inspector dashboard.

Demo Dashboard


Features

  • Zero Config: Just import it, and it will automatically intercept global fetch and XMLHttpRequest requests.
  • 🔗 WebSocket Live Streaming: Streams requests instantly to the local web inspector dashboard (running on port 19796).
  • 🚀 Auto-starting Server: Integrates with the React Native CLI to automatically start the inspector web server in the background when running dev commands like react-native start, run-ios, or run-android.
  • 🖥️ Web Dashboard: View, filter, and inspect your network traffic in any browser at http://localhost:19796.
  • 🤖 Dynamic Metro Detection: Dynamically retrieves the Metro server IP to support simulators, emulators, and physical devices without manual host configuration.
  • 📦 Axios Support: Built-in Axios interceptors to support advanced request/response monitoring, with smart deduplication to prevent double logging.
  • 🛡️ Safe for Production: All operations are guarded by __DEV__ checking, ensuring zero performance overhead or package leakage in production builds.

Installation

Install the package via npm or yarn:

# Using npm
npm install @modhamanish/rn-network-logger

# Using yarn
yarn add @modhamanish/rn-network-logger

Make sure you have react and react-native installed in your project (peer dependencies).


Running the Inspector

1. Automatic Startup (Recommended)

Because of the React Native CLI configuration hook, the inspector web server starts automatically in the background on port 19796 as soon as you start your Metro bundler:

yarn start
# or yarn android / yarn ios

Once your app/bundler is running, simply open your browser and go to: 👉 http://localhost:19796

2. Auto-Starting in Expo Projects

Since Expo CLI ignores React Native CLI configuration hooks, the background server will not start automatically on npx expo start. You can automate this by adding the inspector command to your script definitions in your project's package.json:

"scripts": {
  "start": "rn-network-logger & expo start",
  "android": "rn-network-logger & expo start --android",
  "ios": "rn-network-logger & expo start --ios"
}

Starting your app via yarn start, yarn ios, or yarn android will now automatically launch the inspector server in the background!

3. Manual Startup

If you ever need to start the inspector server manually:

npx rn-network-logger

Then open http://localhost:19796.


Integration Guide

1. Automatic Zero-Config (Global Interceptor)

Simply import the package at the root entry point of your application (usually index.js or App.tsx). It will automatically spin up the WebSocket connection and start intercepting all network requests during development (__DEV__).

// index.js or App.tsx (at the very top)
import '@modhamanish/rn-network-logger';

2. Integration with Axios (Optional)

If your project uses Axios and you want to ensure precise response durations, metadata logging, and handle error payloads cleanly, you can hook up the custom Axios interceptors. The logger automatically detects and deduplicates Axios logs from the global XHR listener.

import axios from 'axios';
import networkLogger from '@modhamanish/rn-network-logger';

const axiosInstance = axios.create({
  baseURL: 'https://api.example.com',
});

// Add Request Interceptor
axiosInstance.interceptors.request.use(
  (config) => {
    return networkLogger.logRequest(config);
  },
  (error) => {
    return Promise.reject(error);
  }
);

// Add Response Interceptor
axiosInstance.interceptors.response.use(
  (response) => {
    return networkLogger.logResponse(response);
  },
  (error) => {
    networkLogger.logError(error);
    return Promise.reject(error);
  }
);

3. Manual Logging API

If you have custom API clients (like WebSockets, gRPC, or custom wrappers) and want to manually log actions to the inspector, you can use the generic logging methods:

Log Request manually:

import networkLogger from '@modhamanish/rn-network-logger';

const requestId = networkLogger.logGenericRequest({
  url: 'https://api.example.com/data',
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: { query: 'React Native' },
});

Log Response manually:

import networkLogger from '@modhamanish/rn-network-logger';

networkLogger.logGenericResponse({
  id: requestId, // Pass the same ID returned from logGenericRequest
  status: 200,
  headers: { 'Content-Type': 'application/json' },
  body: { success: true },
  duration: 150, // in milliseconds
  isError: false,
});

How It Works Under the Hood

  1. Metro IP Lookup: On initialization, the logger reads NativeModules.SourceCode.scriptURL to locate the active Metro Packager host IP address, ensuring it works seamlessly on physical devices connected to the same Wi-Fi network.
  2. Global XHR Monkeypatching: During development, it extends the global XMLHttpRequest to capture send payloads and read response blobs asynchronously.
  3. Queueing mechanism: If the inspector server isn't open or connection drops, logs are safely queued in memory and flushed immediately when reconnection succeeds.