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

react-native-dev-proxy

v1.0.1

Published

Automatically detect React Native platform and rewrite API URLs for local development

Maintainers

khokankhokan

Keywords

react-nativereact nativedevelopmentproxylocalhostandroidiosemulatorsimulatorapinetworkdevelopment-toolsurl-rewritingcross-platformaxiosfetchhttp-clientnetwork erroraxios network errorlocalhost not workingandroid emulatorios simulatorreact native developmentapi developmentmobile developmentreact native axiosreact native fetchnetwork debuggingdevelopment serverlocal developmentreact native localhostandroid localhostios localhostreact native networkmobile apireact native apidevelopment proxyurl rewritenetwork proxyreact native toolsmobile development toolsreact native debuggingnetwork troubleshootingapi testingreact native testingdevelopment environmentreact native environmentmobile environmentreact native setupdevelopment setupreact native configurationnetwork configurationapi configurationreact native networkingmobile networkingreact native httpreact native requestsapi requestshttp requestsnetwork requestsreact native network requestsmobile network requestsdevelopment networkreact native development networkmobile development networkreact native local developmentmobile local developmentreact native local servermobile local serverdevelopment server proxyreact native development servermobile development serverreact native proxy servermobile proxy serverdevelopment proxy serverreact native development proxymobile development proxyreact native network proxymobile network proxyreact native url proxymobile url proxydevelopment url proxyreact native development urlmobile development urlreact native localhost proxymobile localhost proxydevelopment localhost proxyreact native localhost developmentmobile localhost developmentreact native localhost setupmobile localhost setupdevelopment localhost setupreact native localhost configurationmobile localhost configurationdevelopment localhost configurationreact native localhost networkingmobile localhost networkingdevelopment localhost networkingreact native localhost apimobile localhost apidevelopment localhost apireact native localhost requestsmobile localhost requestsdevelopment localhost requestsreact native localhost testingmobile localhost testingdevelopment localhost testingreact native localhost debuggingmobile localhost debuggingdevelopment localhost debuggingreact native localhost troubleshootingmobile localhost troubleshootingdevelopment localhost troubleshootingreact native localhost errormobile localhost errordevelopment localhost errorreact native localhost fixmobile localhost fixdevelopment localhost fixreact native localhost solutionmobile localhost solutiondevelopment localhost solutionreact native localhost workaroundmobile localhost workarounddevelopment localhost workaroundreact native localhost alternativemobile localhost alternativedevelopment localhost alternativereact native localhost replacementmobile localhost replacementdevelopment localhost replacementreact native localhost substitutemobile localhost substitutedevelopment localhost substitutereact native localhost equivalentmobile localhost equivalentdevelopment localhost equivalentreact native localhost similarmobile localhost similardevelopment localhost similarreact native localhost likemobile localhost likedevelopment localhost likereact native localhost comparablemobile localhost comparabledevelopment localhost comparablereact native localhost matchingmobile localhost matchingdevelopment localhost matchingreact native localhost correspondingmobile localhost correspondingdevelopment localhost correspondingreact native localhost relatedmobile localhost relateddevelopment localhost relatedreact native localhost associatedmobile localhost associateddevelopment localhost associatedreact native localhost connectedmobile localhost connecteddevelopment localhost connectedreact native localhost linkedmobile localhost linkeddevelopment localhost linkedreact native localhost tiedmobile localhost tieddevelopment localhost tiedreact native localhost boundmobile localhost bounddevelopment localhost boundreact native localhost attachedmobile localhost attacheddevelopment localhost attachedreact native localhost joinedmobile localhost joineddevelopment localhost joinedreact native localhost combinedmobile localhost combineddevelopment localhost combinedreact native localhost mergedmobile localhost mergeddevelopment localhost mergedreact native localhost integratedmobile localhost integrateddevelopment localhost integratedreact native localhost unifiedmobile localhost unifieddevelopment localhost unifiedreact native localhost consolidatedmobile localhost consolidateddevelopment localhost consolidatedreact native localhost centralizedmobile localhost centralizeddevelopment localhost centralizedreact native localhost coordinatedmobile localhost coordinateddevelopment localhost coordinatedreact native localhost synchronizedmobile localhost synchronizeddevelopment localhost synchronizedreact native localhost alignedmobile localhost aligneddevelopment localhost alignedreact native localhost harmonizedmobile localhost harmonizeddevelopment localhost harmonizedreact native localhost balancedmobile localhost balanceddevelopment localhost balancedreact native localhost equalizedmobile localhost equalizeddevelopment localhost equalizedreact native localhost standardizedmobile localhost standardizeddevelopment localhost standardizedreact native localhost normalizedmobile localhost normalizeddevelopment localhost normalizedreact native localhost regularizedmobile localhost regularizeddevelopment localhost regularizedreact native localhost systematizedmobile localhost systematizeddevelopment localhost systematizedreact native localhost organizedmobile localhost organizeddevelopment localhost organizedreact native localhost structuredmobile localhost structureddevelopment localhost structuredreact native localhost arrangedmobile localhost arrangeddevelopment localhost arrangedreact native localhost orderedmobile localhost ordereddevelopment localhost orderedreact native localhost sequencedmobile localhost sequenceddevelopment localhost sequencedreact native localhost prioritizedmobile localhost prioritizeddevelopment localhost prioritizedreact native localhost rankedmobile localhost rankeddevelopment localhost rankedreact native localhost classifiedmobile localhost classifieddevelopment localhost classifiedreact native localhost categorizedmobile localhost categorizeddevelopment localhost categorizedreact native localhost groupedmobile localhost groupeddevelopment localhost groupedreact native localhost clusteredmobile localhost clustereddevelopment localhost clusteredreact native localhost bundledmobile localhost bundleddevelopment localhost bundledreact native localhost packagedmobile localhost packageddevelopment localhost packagedreact native localhost wrappedmobile localhost wrappeddevelopment localhost wrappedreact native localhost coveredmobile localhost covereddevelopment localhost coveredreact native localhost protectedmobile localhost protecteddevelopment localhost protectedreact native localhost securedmobile localhost secureddevelopment localhost securedreact native localhost safemobile localhost safedevelopment localhost safereact native localhost securemobile localhost securedevelopment localhost securereact native localhost reliablemobile localhost reliabledevelopment localhost reliablereact native localhost stablemobile localhost stabledevelopment localhost stablereact native localhost consistentmobile localhost consistentdevelopment localhost consistentreact native localhost predictablemobile localhost predictabledevelopment localhost predictablereact native localhost dependablemobile localhost dependabledevelopment localhost dependablereact native localhost trustworthymobile localhost trustworthydevelopment localhost trustworthyreact native localhost crediblemobile localhost credibledevelopment localhost crediblereact native localhost authenticmobile localhost authenticdevelopment localhost authenticreact native localhost genuinemobile localhost genuinedevelopment localhost genuinereact native localhost realmobile localhost realdevelopment localhost realreact native localhost actualmobile localhost actualdevelopment localhost actualreact native localhost truemobile localhost truedevelopment localhost truereact native localhost validmobile localhost validdevelopment localhost validreact native localhost legitimatemobile localhost legitimatedevelopment localhost legitimatereact native localhost officialmobile localhost officialdevelopment localhost officialreact native localhost authorizedmobile localhost authorizeddevelopment localhost authorizedreact native localhost approvedmobile localhost approveddevelopment localhost approvedreact native localhost certifiedmobile localhost certifieddevelopment localhost certifiedreact native localhost verifiedmobile localhost verifieddevelopment localhost verifiedreact native localhost confirmedmobile localhost confirmeddevelopment localhost confirmedreact native localhost establishedmobile localhost establisheddevelopment localhost establishedreact native localhost provenmobile localhost provendevelopment localhost provenreact native localhost testedmobile localhost testeddevelopment localhost testedreact native localhost triedmobile localhost trieddevelopment localhost triedreact native localhost attemptedmobile localhost attempteddevelopment localhost attemptedreact native localhost experimentedmobile localhost experimenteddevelopment localhost experimentedreact native localhost pilotedmobile localhost piloteddevelopment localhost pilotedreact native localhost prototypedmobile localhost prototypeddevelopment localhost prototypedreact native localhost modeledmobile localhost modeleddevelopment localhost modeledreact native localhost simulatedmobile localhost simulateddevelopment localhost simulatedreact native localhost replicatedmobile localhost replicateddevelopment localhost replicatedreact native localhost duplicatedmobile localhost duplicateddevelopment localhost duplicatedreact native localhost copiedmobile localhost copieddevelopment localhost copiedreact native localhost clonedmobile localhost cloneddevelopment localhost clonedreact native localhost mirroredmobile localhost mirroreddevelopment localhost mirroredreact native localhost reflectedmobile localhost reflecteddevelopment localhost reflectedreact native localhost echoedmobile localhost echoeddevelopment localhost echoedreact native localhost repeatedmobile localhost repeateddevelopment localhost repeatedreact native localhost reiteratedmobile localhost reiterateddevelopment localhost reiteratedreact native localhost restatedmobile localhost restateddevelopment localhost restatedreact native localhost rephrasedmobile localhost rephraseddevelopment localhost rephrasedreact native localhost paraphrasedmobile localhost paraphraseddevelopment localhost paraphrasedreact native localhost summarizedmobile localhost summarizeddevelopment localhost summarizedreact native localhost condensedmobile localhost condenseddevelopment localhost condensedreact native localhost compressedmobile localhost compresseddevelopment localhost compressedreact native localhost compactedmobile localhost compacteddevelopment localhost compactedreact native localhost reducedmobile localhost reduceddevelopment localhost reducedreact native localhost minimizedmobile localhost minimizeddevelopment localhost minimizedreact native localhost optimizedmobile localhost optimizeddevelopment localhost optimizedreact native localhost enhancedmobile localhost enhanceddevelopment localhost enhancedreact native localhost improvedmobile localhost improveddevelopment localhost improvedreact native localhost upgradedmobile localhost upgradeddevelopment localhost upgradedreact native localhost updatedmobile localhost updateddevelopment localhost updatedreact native localhost modernizedmobile localhost modernizeddevelopment localhost modernizedreact native localhost refreshedmobile localhost refresheddevelopment localhost refreshedreact native localhost renewedmobile localhost reneweddevelopment localhost renewedreact native localhost revitalizedmobile localhost revitalizeddevelopment localhost revitalizedreact native localhost rejuvenatedmobile localhost rejuvenateddevelopment localhost rejuvenatedreact native localhost restoredmobile localhost restoreddevelopment localhost restoredreact native localhost repairedmobile localhost repaireddevelopment localhost repairedreact native localhost fixedmobile localhost fixeddevelopment localhost fixedreact native localhost correctedmobile localhost correcteddevelopment localhost correctedreact native localhost adjustedmobile localhost adjusteddevelopment localhost adjustedreact native localhost modifiedmobile localhost modifieddevelopment localhost modifiedreact native localhost alteredmobile localhost altereddevelopment localhost alteredreact native localhost changedmobile localhost changeddevelopment localhost changedreact native localhost transformedmobile localhost transformeddevelopment localhost transformedreact native localhost convertedmobile localhost converteddevelopment localhost convertedreact native localhost translatedmobile localhost translateddevelopment localhost translatedreact native localhost interpretedmobile localhost interpreteddevelopment localhost interpretedreact native localhost decodedmobile localhost decodeddevelopment localhost decodedreact native localhost decryptedmobile localhost decrypteddevelopment localhost decryptedreact native localhost decipheredmobile localhost deciphereddevelopment localhost decipheredreact native localhost unencryptedmobile localhost unencrypteddevelopment localhost unencryptedreact native localhost unsecuredmobile localhost unsecureddevelopment localhost unsecuredreact native localhost unprotectedmobile localhost unprotecteddevelopment localhost unprotectedreact native localhost vulnerablemobile localhost vulnerabledevelopment localhost vulnerablereact native localhost exposedmobile localhost exposeddevelopment localhost exposedreact native localhost openmobile localhost opendevelopment localhost openreact native localhost accessiblemobile localhost accessibledevelopment localhost accessiblereact native localhost availablemobile localhost availabledevelopment localhost availablereact native localhost reachablemobile localhost reachabledevelopment localhost reachablereact native localhost connectablemobile localhost connectabledevelopment localhost connectablereact native localhost linkablemobile localhost linkabledevelopment localhost linkablereact native localhost joinablemobile localhost joinabledevelopment localhost joinablereact native localhost attachablemobile localhost attachabledevelopment localhost attachablereact native localhost bindablemobile localhost bindabledevelopment localhost bindablereact native localhost tieablemobile localhost tieabledevelopment localhost tieablereact native localhost fastenablemobile localhost fastenabledevelopment localhost fastenablereact native localhost securablemobile localhost securabledevelopment localhost securablereact native localhost lockablemobile localhost lockabledevelopment localhost lockablereact native localhost closablemobile localhost closabledevelopment localhost closablereact native localhost sealablemobile localhost sealabledevelopment localhost sealablereact native localhost pluggablemobile localhost pluggabledevelopment localhost pluggablereact native localhost stoppablemobile localhost stoppabledevelopment localhost stoppablereact native localhost blockablemobile localhost blockabledevelopment localhost blockablereact native localhost preventiblemobile localhost preventibledevelopment localhost preventiblereact native localhost avoidablemobile localhost avoidabledevelopment localhost avoidablereact native localhost escapablemobile localhost escapabledevelopment localhost escapablereact native localhost evadablemobile localhost evadabledevelopment localhost evadablereact native localhost eludablemobile localhost eludabledevelopment localhost eludablereact native localhost dodgeablemobile localhost dodgeabledevelopment localhost dodgeablereact native localhost sidestepablemobile localhost sidestepabledevelopment localhost sidestepablereact native localhost circumventablemobile localhost circumventabledevelopment localhost circumventablereact native localhost bypassablemobile localhost bypassabledevelopment localhost bypassablereact native localhost skippablemobile localhost skippabledevelopment localhost skippablereact native localhost omittablemobile localhost omittabledevelopment localhost omittablereact native localhost excludablemobile localhost excludabledevelopment localhost excludablereact native localhost eliminablemobile localhost eliminabledevelopment localhost eliminablereact native localhost removablemobile localhost removabledevelopment localhost removablereact native localhost deletablemobile localhost deletabledevelopment localhost deletablereact native localhost erasablemobile localhost erasabledevelopment localhost erasablereact native localhost clearablemobile localhost clearabledevelopment localhost clearablereact native localhost cleanablemobile localhost cleanabledevelopment localhost cleanablereact native localhost washablemobile localhost washabledevelopment localhost washablereact native localhost rinseablemobile localhost rinseabledevelopment localhost rinseablereact native localhost flushablemobile localhost flushabledevelopment localhost flushablereact native localhost drainablemobile localhost drainabledevelopment localhost drainablereact native localhost emptyablemobile localhost emptyabledevelopment localhost emptyablereact native localhost voidablemobile localhost voidabledevelopment localhost voidablereact native localhost nullifiablemobile localhost nullifiabledevelopment localhost nullifiablereact native localhost cancelablemobile localhost cancelabledevelopment localhost cancelablereact native localhost abortablemobile localhost abortabledevelopment localhost abortablereact native localhost terminablemobile localhost terminabledevelopment localhost terminablereact native localhost endablemobile localhost endabledevelopment localhost endablereact native localhost finishablemobile localhost finishabledevelopment localhost finishablereact native localhost completablemobile localhost completabledevelopment localhost completablereact native localhost finalizablemobile localhost finalizabledevelopment localhost finalizablereact native localhost closablemobile localhost closabledevelopment localhost closablereact native localhost sealablemobile localhost sealabledevelopment localhost sealablereact native localhost pluggablemobile localhost pluggabledevelopment localhost pluggablereact native localhost stoppablemobile localhost stoppabledevelopment localhost stoppablereact native localhost blockablemobile localhost blockabledevelopment localhost blockablereact native localhost preventiblemobile localhost preventibledevelopment localhost preventiblereact native localhost avoidablemobile localhost avoidabledevelopment localhost avoidablereact native localhost escapablemobile localhost escapabledevelopment localhost escapablereact native localhost evadablemobile localhost evadabledevelopment localhost evadablereact native localhost eludablemobile localhost eludabledevelopment localhost eludablereact native localhost dodgeablemobile localhost dodgeabledevelopment localhost dodgeablereact native localhost sidestepablemobile localhost sidestepabledevelopment localhost sidestepablereact native localhost circumventablemobile localhost circumventabledevelopment localhost circumventablereact native localhost bypassablemobile localhost bypassabledevelopment localhost bypassablereact native localhost skippablemobile localhost skippabledevelopment localhost skippablereact native localhost omittablemobile localhost omittabledevelopment localhost omittablereact native localhost excludablemobile localhost excludabledevelopment localhost excludablereact native localhost eliminablemobile localhost eliminabledevelopment localhost eliminablereact native localhost removablemobile localhost removabledevelopment localhost removablereact native localhost deletablemobile localhost deletabledevelopment localhost deletablereact native localhost erasablemobile localhost erasabledevelopment localhost erasablereact native localhost clearablemobile localhost clearabledevelopment localhost clearablereact native localhost cleanablemobile localhost cleanabledevelopment localhost cleanablereact native localhost washablemobile localhost washabledevelopment localhost washablereact native localhost rinseablemobile localhost rinseabledevelopment localhost rinseablereact native localhost flushablemobile localhost flushabledevelopment localhost flushablereact native localhost drainablemobile localhost drainabledevelopment localhost drainablereact native localhost emptyablemobile localhost emptyabledevelopment localhost emptyablereact native localhost voidablemobile localhost voidabledevelopment localhost voidablereact native localhost nullifiablemobile localhost nullifiabledevelopment localhost nullifiablereact native localhost cancelablemobile localhost cancelabledevelopment localhost cancelablereact native localhost abortablemobile localhost abortabledevelopment localhost abortablereact native localhost terminablemobile localhost terminabledevelopment localhost terminablereact native localhost endablemobile localhost endabledevelopment localhost endablereact native localhost finishablemobile localhost finishabledevelopment localhost finishablereact native localhost completablemobile localhost completabledevelopment localhost completablereact native localhost finalizablemobile localhost finalizabledevelopment localhost finalizable

Readme

🚀 React Native Dev Proxy

npm version License: MIT Downloads

Automatically detect React Native platform and rewrite API URLs for local development

🎯 The Problem This Solves

When developing React Native apps, you often face this frustrating issue:

// ❌ This works in iOS Simulator but fails on Android device
const response = await fetch('http://localhost:8000/api/users');
// Error: Network request failed

Why does this happen?

  • iOS Simulator can access localhost directly
  • Android Emulator needs 10.0.2.2 instead of localhost
  • Physical devices need your computer's actual IP address
  • Different platforms require different URL configurations

✨ The Solution

react-native-dev-proxy automatically handles URL rewriting for you:

// ✅ This works everywhere - iOS, Android, simulators, and devices
import { withDevProxy } from 'react-native-dev-proxy';
import axios from 'axios';

const api = withDevProxy(axios.create({
  baseURL: 'http://localhost:8000',
}), { strategy: 'auto' });

const users = await api.get('/api/users'); // Works everywhere!

🚀 Quick Start

1. Install the Package

npm install react-native-dev-proxy
# or
yarn add react-native-dev-proxy

2. Apply the Patch

npx rn-dev-proxy patch

Apply Patch GIF Running the patch command to configure your React Native project

3. Wrap Your API Client

import { withDevProxy } from 'react-native-dev-proxy';
import axios from 'axios';

const api = withDevProxy(
  axios.create({
    baseURL: 'http://localhost:8000',
    timeout: 10000,
  }),
  {
    strategy: 'auto', // Automatically choose the best method
    log: true,        // Show URL rewriting logs
  }
);

// Now your API calls work everywhere!
const users = await api.get('/api/users');

Code Integration GIF See how easy it is to integrate with your existing code

📱 Platform Support

| Platform | Original URL | Rewritten URL | Status | |----------|-------------|---------------|---------| | iOS Simulator | localhost:8000 | localhost:8000 | ✅ Works | | Android Emulator | localhost:8000 | 10.0.2.2:8000 | ✅ Works | | Physical iOS Device | localhost:8000 | 192.168.1.100:8000 | ✅ Works | | Physical Android Device | localhost:8000 | 192.168.1.100:8000 | ✅ Works |

Platform Support GIF See how the proxy automatically adapts to different platforms

Platform Screenshots

iOS Simulator iOS Simulator working with localhost

Android Emulator Android Emulator working with 10.0.2.2

Physical Device Physical device working with IP address

🛠️ API Reference

withDevProxy(apiClient, options)

Wraps your API client with automatic URL rewriting.

Parameters:

  • `apiClient: Your API client (axios, fetch, etc.)
  • options: Configuration object

Options:

{
  strategy: 'auto' | 'lan' | 'tunnel', // URL rewriting strategy
  log: boolean,                         // Enable logging
  baseURL: string,                      // Base URL to rewrite
}

makeFetch(options)

Creates a fetch wrapper with automatic URL rewriting.

Parameters:

  • options: Configuration object (same as above)

🎯 Usage Examples

Axios Integration

import { withDevProxy } from 'react-native-dev-proxy';
import axios from 'axios';

const api = withDevProxy(
  axios.create({
    baseURL: 'http://localhost:8000',
    timeout: 10000,
  }),
  { strategy: 'auto', log: true }
);

// All these work automatically on any platform
const users = await api.get('/api/users');
const user = await api.post('/api/users', { name: 'John' });
const updated = await api.put('/api/users/1', { name: 'Jane' });
const deleted = await api.delete('/api/users/1');

Fetch Integration

import { makeFetch } from 'react-native-dev-proxy';

const fetchApi = makeFetch({
  baseURL: 'http://localhost:8000',
  strategy: 'auto',
  log: true,
});

// Works everywhere
const response = await fetchApi('/api/users');
const data = await response.json();

React Hook Example

import { useState, useEffect } from 'react';
import { withDevProxy } from 'react-native-dev-proxy';
import axios from 'axios';

const api = withDevProxy(
  axios.create({ baseURL: 'http://localhost:8000' }),
  { strategy: 'auto', log: true }
);

const useUsers = () => {
  const [users, setUsers] = useState([]);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    const fetchUsers = async () => {
      try {
        const response = await api.get('/api/users');
        setUsers(response.data);
      } catch (error) {
        console.error('Failed to fetch users:', error);
      } finally {
        setLoading(false);
      }
    };

    fetchUsers();
  }, []);

  return { users, loading };
};

🔧 Configuration Options

Strategy Options:

  • auto (recommended): Automatically detects the best method
  • lan: Always uses your computer's IP address
  • tunnel: Uses tunneling service (ngrok, etc.)

Logging:

// Enable detailed logging
const api = withDevProxy(axios, { 
  strategy: 'auto', 
  log: true 
});

// Console output:
// 🔧 [DevProxy] Detected platform: android
// 🔧 [DevProxy] Using strategy: lan
// 🔧 [DevProxy] Rewriting URL: http://localhost:8000/api/users
// 🔧 [DevProxy] To: http://192.168.1.100:8000/api/users
// 📡 [DevProxy] Request successful: 200 OK

🧪 Testing Your Setup

Create a simple test component:

import React, { useState } from 'react';
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
import { withDevProxy } from 'react-native-dev-proxy';
import axios from 'axios';

const api = withDevProxy(
  axios.create({ baseURL: 'http://localhost:8000' }),
  { strategy: 'auto', log: true }
);

const TestComponent = () => {
  const [result, setResult] = useState('');

  const testAPI = async () => {
    try {
      const response = await api.get('/api/ping');
      setResult(`✅ Success: ${JSON.stringify(response.data)}`);
    } catch (error) {
      setResult(`❌ Error: ${error.message}`);
    }
  };

  return (
    <View style={styles.container}>
      <TouchableOpacity style={styles.button} onPress={testAPI}>
        <Text style={styles.buttonText}>Test API</Text>
      </TouchableOpacity>
      <Text style={styles.result}>{result}</Text>
    </View>
  );
};

const styles = StyleSheet.create({
  container: { flex: 1, justifyContent: 'center', alignItems: 'center' },
  button: { backgroundColor: '#007AFF', padding: 15, borderRadius: 8 },
  buttonText: { color: 'white', fontWeight: 'bold' },
  result: { marginTop: 20, textAlign: 'center' },
});

export default TestComponent;

Testing Setup GIF Watch the test component in action across different platforms

🔧 Advanced Configuration

Custom Base URL

const api = withDevProxy(axios, {
  baseURL: 'http://localhost:3000', // Your custom server
  strategy: 'auto',
  log: true,
});

Environment-Specific Configuration

const isDevelopment = __DEV__;
const baseURL = isDevelopment 
  ? 'http://localhost:8000' 
  : 'https://api.yourapp.com';

const api = withDevProxy(axios.create({ baseURL }), {
  strategy: isDevelopment ? 'auto' : 'lan',
  log: isDevelopment,
});

🐛 Troubleshooting

Common Issues:

1. "Network request failed" error:

  • Ensure your server is running on the correct port
  • Check that adb reverse is set up for Android
  • Verify your computer and device are on the same network

2. URLs not being rewritten:

  • Make sure you're using the wrapped API client
  • Check that the patch was applied correctly
  • Verify the baseURL matches your server

3. iOS Simulator issues:

  • Try using 127.0.0.1 instead of localhost
  • Check your server's CORS settings

Debug Steps:

  1. Enable logging:
const api = withDevProxy(axios, { log: true });
  1. Check console output:
🔧 [DevProxy] Detected platform: android
🔧 [DevProxy] Using strategy: lan
🔧 [DevProxy] Rewriting URL: http://localhost:8000/api/users
  1. Test with curl:
curl http://localhost:8000/api/users

Troubleshooting GIF See how to debug and fix common issues

Console Logging

Console Logs Detailed console logging showing URL rewriting

Patch Command Output

Patch Output Patch command successfully configuring your project

Code Editor Integration

Code Editor Easy integration in your code editor

Network Architecture

Network Diagram Visual representation of how the proxy works

Error Handling

Error Handling Comprehensive error handling and debugging

📚 Examples Repository

Check out our examples repository for:

  • Complete React Native app examples
  • Different API client integrations
  • Testing setups
  • Production configurations

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

MIT License - see LICENSE file for details.

🙏 Acknowledgments

  • React Native community for the amazing platform
  • Contributors who helped make this package better
  • All the developers who faced this problem before us

📞 Support


Made with ❤️ for the React Native community