@@ -8,8 +8,7 @@ A comprehensive network request debugging tool for React Native applications. Mo
88[ ![ Platform] ( https://img.shields.io/badge/platform-react--native-blue )] ( https://reactnative.dev/ )
99[ ![ TypeScript] ( https://img.shields.io/badge/typescript-supported-blue )] ( https://www.typescriptlang.org/ )
1010
11-
12- ![ React Native API Debugger] ( demo/rn-api-debugger-demo.gif )
11+ ![ React Native API Debugger] ( github.com/user-attachments/assets/b4d8b9a3-35dc-4f51-8cc5-3f226b80d709 )
1312
1413## ✨ Features
1514
@@ -20,6 +19,7 @@ A comprehensive network request debugging tool for React Native applications. Mo
2019- 🔎 ** Advanced Filtering** - Search and filter by URL, method, status, or API endpoints
2120- ❌ ** Error Tracking** - Easily identify failed requests and network errors
2221- 📱 ** Device Shake Support** - Optional shake-to-show/hide functionality
22+ - 📋 ** Copy to Clipboard** - Optionally copy request/response/cURL details
2323- 🎨 ** Customizable UI** - Configure header visibility and other display options
2424- 🚀 ** TypeScript Support** - Full TypeScript definitions included
2525- 💾 ** Memory Efficient** - Automatic cleanup with configurable request limits
@@ -30,33 +30,34 @@ A comprehensive network request debugging tool for React Native applications. Mo
3030npm install react-native-api-debugger
3131```
3232
33- ### Required Peer Dependencies
34-
35- Install the required peer dependencies for full functionality:
33+ > ** Note:** Features like draggable overlay, device shake, and clipboard copy require additional peer dependencies.
34+ > The debugger will throw a clear error if you enable a feature and the relevant library is not installed.
3635
37- ``` bash
38- # Required for clipboard functionality
39- npm install @react-native-clipboard/clipboard
36+ ### Optional Peer Dependencies
4037
41- # Required for device shake support
42- npm install react-native-shake
38+ Install these only if you need advanced features:
4339
44- # Required for draggable floating button
45- npm install react-native-gesture-handler react-native-reanimated
40+ ``` bash
41+ npm install @react-native-clipboard/clipboard # For copy to clipboard
42+ npm install react-native-shake # For device shake to show/hide
43+ npm install react-native-gesture-handler # For draggable floating button
44+ npm install react-native-reanimated # (Required for gesture handler)
4645```
4746
48- > ** Note** : For Expo SDK ≤ 53, use ` react-native-reanimated ` version 3.x.x
47+ > ** Note: ** For Expo SDK ≤ 53, use ` react-native-reanimated ` version 3.x.x
4948
5049### Platform Setup
5150
52- After installing peer dependencies, follow their respective setup guides:
51+ If you use ** draggable overlay ** or ** device shake ** , also follow their respective setup guides:
5352
5453- ** react-native-gesture-handler** : [ Installation Guide] ( https://docs.swmansion.com/react-native-gesture-handler/docs/installation )
5554- ** react-native-reanimated** : [ Installation Guide] ( https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started )
5655
56+ ---
57+
5758## 🚀 Quick Start
5859
59- ### Basic Usage
60+ ### Minimal Example
6061
6162``` typescript
6263import React , { useEffect } from ' react' ;
@@ -65,51 +66,46 @@ import { networkLogger, NetworkLoggerOverlay } from 'react-native-api-debugger';
6566
6667export default function App() {
6768 useEffect (() => {
68- // Initialize the network logger
6969 networkLogger .setupInterceptor ();
7070 }, []);
7171
7272 return (
7373 < View style = {{ flex : 1 }}>
7474 {/* Your app content */ }
75-
76- {/* Add the network logger overlay */ }
77- < NetworkLoggerOverlay networkLogger = {networkLogger } / >
75+
76+ {/* Minimal usage: All advanced features turned off */ }
77+ < NetworkLoggerOverlay
78+ draggable = {false }
79+ enableDeviceShake = {false }
80+ useCopyToClipboard = {false }
81+ showRequestHeader = {false }
82+ showResponseHeader = {false }
83+ networkLogger = {networkLogger }
84+ / >
7885 < / View >
7986 );
8087}
8188```
8289
83- ### With All Features Enabled
90+ ---
91+
92+ ### Full Features Example
8493
8594``` typescript
86- import React , { useEffect } from ' react' ;
87- import { View } from ' react-native' ;
88- import { networkLogger , NetworkLoggerOverlay } from ' react-native-api-debugger' ;
89- import { GestureHandlerRootView } from ' react-native-gesture-handler' ;
95+ < NetworkLoggerOverlay
96+ networkLogger = {networkLogger }
97+ draggable = {true } // Requires react-native-gesture-handler & react-native-reanimated
98+ enableDeviceShake = {true } // Requires react-native-shake
99+ useCopyToClipboard = {true } // Requires @react-native-clipboard/clipboard
100+ showRequestHeader = {true }
101+ showResponseHeader = {true }
102+ / >
103+ ```
90104
91- export default function App() {
92- useEffect (() => {
93- networkLogger .setupInterceptor ();
94- }, []);
105+ > ⚠️ ** Important:**
106+ > If you enable ` draggable ` , ` enableDeviceShake ` , or ` useCopyToClipboard ` ** without installing the corresponding peer dependency** , the debugger will throw a descriptive error at runtime, guiding you to install the required package.
95107
96- return (
97- < GestureHandlerRootView style = {{ flex : 1 }}>
98- < View style = {{ flex : 1 }}>
99- {/* Your app content */ }
100-
101- < NetworkLoggerOverlay
102- networkLogger = {networkLogger }
103- enableDeviceShake = {true }
104- draggable = {true }
105- showRequestHeader = {true }
106- showResponseHeader = {true }
107- / >
108- < / View >
109- < / GestureHandlerRootView >
110- );
111- }
112- ```
108+ ---
113109
114110## 📚 API Reference
115111
@@ -122,8 +118,9 @@ The main UI component that displays the network logs with a draggable floating b
122118| Prop | Type | Default | Description |
123119| ------| ------| ---------| -------------|
124120| ` networkLogger ` | ` NetworkLogger ` | ** Required** | The network logger instance |
125- | ` enableDeviceShake ` | ` boolean ` | ` false ` | Enable shake-to-show/hide functionality |
126- | ` draggable ` | ` boolean ` | ` false ` | Enable draggable floating button (requires GestureHandlerRootView) |
121+ | ` enableDeviceShake ` | ` boolean ` | ` false ` | Enable shake-to-show/hide functionality * (requires ` react-native-shake ` )* |
122+ | ` draggable ` | ` boolean ` | ` false ` | Enable draggable floating button * (requires ` react-native-gesture-handler ` and ` react-native-reanimated ` )* |
123+ | ` useCopyToClipboard ` | ` boolean ` | ` false ` | Enable copy to clipboard * (requires ` @react-native-clipboard/clipboard ` )* |
127124| ` showRequestHeader ` | ` boolean ` | ` false ` | Display request headers in log details |
128125| ` showResponseHeader ` | ` boolean ` | ` false ` | Display response headers in log details |
129126
@@ -133,17 +130,18 @@ The main UI component that displays the network logs with a draggable floating b
133130// Minimal setup
134131< NetworkLoggerOverlay networkLogger = {networkLogger } / >
135132
136- // With device shake support
133+ // With device shake support (if installed)
137134< NetworkLoggerOverlay
138135 networkLogger = {networkLogger }
139136 enableDeviceShake = {true }
140137/ >
141138
142- // Full-featured setup
139+ // Full-featured setup (requires peer dependencies)
143140< NetworkLoggerOverlay
144141 networkLogger = {networkLogger }
145142 enableDeviceShake = {true }
146143 draggable = {true }
144+ useCopyToClipboard = {true }
147145 showRequestHeader = {true }
148146 showResponseHeader = {true }
149147/ >
@@ -186,41 +184,15 @@ export default function App() {
186184 networkLogger = {networkLogger }
187185 enableDeviceShake = {true }
188186 draggable = {true }
187+ useCopyToClipboard = {true }
189188 />
190189 )}
191190 < / View >
192191 );
193192}
194193```
195194
196- ### Custom Logger Configuration
197-
198- ``` typescript
199- import { createNetworkLogger } from ' react-native-api-debugger' ;
200-
201- // Create a custom logger with specific configuration
202- const customLogger = createNetworkLogger ({
203- maxRequests: 50 , // Limit stored requests
204- enabledInProduction: false ,
205- excludeUrls: [
206- / analytics\. example\. com/ ,
207- / tracking\. service\. com/
208- ]
209- });
210-
211- // Use the custom logger
212- export default function App() {
213- useEffect (() => {
214- customLogger .setupInterceptor ();
215- }, []);
216-
217- return (
218- < View style = {{ flex : 1 }}>
219- < NetworkLoggerOverlay networkLogger = {customLogger } / >
220- < / View >
221- );
222- }
223- ```
195+ ---
224196
225197## 🎯 TypeScript Support
226198
@@ -269,47 +241,12 @@ export default function App() {
269241}
270242```
271243
272- #### Metro Configuration (React Native ≥ 0.72)
273- Add to your ` metro.config.js ` :
274- ``` javascript
275- const { getDefaultConfig } = require (' expo/metro-config' );
276-
277- const config = getDefaultConfig (__dirname );
278-
279- config .resolver .alias = {
280- ' react-native-api-debugger' : require .resolve (' react-native-api-debugger' ),
281- };
282-
283- module .exports = config;
284- ```
285-
286244### Performance Considerations
287245
288246- ** Memory Management** : The logger automatically limits stored requests to prevent memory issues (default: 100 requests)
289247- ** Production Builds** : Always disable in production to avoid performance impact
290248- ** Large Responses** : Consider filtering or truncating large response bodies
291249
292- ## 🔐 Security & Best Practices
293-
294- ### Sensitive Data Handling
295-
296- ⚠️ ** Important** : The logger captures all headers and request/response bodies.
297-
298- ``` typescript
299- // Recommended: Only enable in development
300- if (__DEV__ ) {
301- networkLogger .setupInterceptor ();
302- }
303-
304- // For sensitive endpoints, consider URL exclusions
305- const logger = createNetworkLogger ({
306- excludeUrls: [
307- / \/ auth\/ login/ ,
308- / \/ payment\/ / ,
309- / api\. stripe\. com/
310- ]
311- });
312- ```
313250
314251### Production Safety
315252
0 commit comments