A powerful React Native library that allows you to track and inspect all network requests in your app. Perfect for debugging, monitoring, and understanding your app's network behavior.
- π Automatic Request Tracking: Captures all OkHttp network requests automatically
- π Debug-Only: Zero overhead in production builds (only active in debug mode)
- π Detailed Information: Captures request/response headers, bodies, timing, and errors
- πΎ In-Memory Storage: Stores up to 100 recent requests with automatic cleanup
- π Thread-Safe: Built with concurrent data structures for reliability
- β‘ Easy Integration: Simple API with minimal setup required
npm install react-native-network-tools
# or
yarn add react-native-network-toolsAdd the interceptor to your MainApplication.kt:
import com.networktools.NetworkToolsManager
import okhttp3.OkHttpClient
class MainApplication : Application(), ReactApplication {
override fun onCreate() {
super.onCreate()
NetworkingModule.setCustomClientBuilder(
object : NetworkingModule.CustomClientBuilder {
override fun apply(builder: OkHttpClient.Builder) {
NetworkToolsManager.addInterceptor(builder)
}
}
)
// rest code
}
}import { NetworkMonitorProvider } from 'react-native-network-tools';
function App() {
return (
<NetworkMonitorProvider
maxRequests={1000}
showFloatingMonitor={true}
>
{/* Your app code */}
</NetworkMonitorProvider>
);
}import * as NetworkTools from 'react-native-network-tools';
// Get all requests
const requests = NetworkTools.getAllRequests();
// Get specific request
const request = NetworkTools.getRequestById('request-id');
// Clear all requests
NetworkTools.clearAllRequests();
// Get request count
const count = NetworkTools.getRequestCount();Get all captured network requests.
Get a specific network request by its unique ID.
Clear all stored network requests from memory.
Get the total count of stored network requests.
interface NetworkRequest {
id: string;
url: string;
method: string;
requestHeaders: Record<string, string>;
requestBody?: string;
requestTime: number;
responseCode?: number;
responseHeaders?: Record<string, string>;
responseBody?: string;
responseTime?: number;
duration?: number;
error?: string;
}The library automatically enables tracking only in debug builds. You can customize this behavior:
buildTypes {
debug {
buildConfigField "boolean", "NETWORK_TOOLS_ENABLED", "true"
}
staging {
buildConfigField "boolean", "NETWORK_TOOLS_ENABLED", "true"
}
release {
buildConfigField "boolean", "NETWORK_TOOLS_ENABLED", "false"
}
}For detailed setup instructions, custom configurations, and advanced usage patterns, see the Setup Guide.
- β Android (via OkHttp interceptor)
- π§ iOS (coming soon)
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library