The `react-native-http-bridge-refurbished` package provides a lightweight, in-app HTTP server designed for debugging React Native applications. It allows developers to expose an HTTP endpoint directly from their mobile app, facilitating interaction, data inspection, and remote control for development purposes. Currently stable at version `1.3.2`, the project sees sporadic but active maintenance, with recent updates addressing bug fixes and minor feature enhancements, such as improved URL parameter handling. As a 'refurbished' version of an earlier, potentially unmaintained library, its key differentiator is its continued support and compatibility with modern React Native versions (requiring `>=0.72`), offering a robust alternative for in-app web server functionalities.
npm install react-native-http-bridge-refurbishedVerified import paths — ran on the pinned version, not inferred.
Demonstrates starting an HTTP debug server within a React Native app, registering two GET routes (`/` and `/echo`), and handling incoming requests to provide a basic JSON or text response. It also shows how to stop the server and displays the last received request.
Ensure your project's `react-native` version is `>=0.72` or downgrade `react-native-http-bridge-refurbished` to a compatible version.
Upgrade to `react-native-http-bridge-refurbished@1.2.8` or newer to resolve known Android build stability problems.
Upgrade to `react-native-http-bridge-refurbished@1.2.4` or newer to prevent potential iOS crashes.
Use a tool to find your device's local IP address (e.g., in Wi-Fi settings or `adb shell ip addr show wlan0` for Android) and ensure your development machine and device are on the same network. Temporarily disable strict firewall rules if necessary for debugging.
Add `<uses-permission android:name="android.permission.INTERNET" />` inside the `<manifest>` tag in your `android/app/src/main/AndroidManifest.xml` file.
Run `npx react-native link react-native-http-bridge-refurbished` to manually link the module. If the problem persists, try clearing Metro Bundler's cache (`npx react-native start --reset-cache`) and reinstalling node modules (`rm -rf node_modules && npm install` or `yarn install`).
Verify the IP address of your device (e.g., emulator/simulator IP or physical device's Wi-Fi IP). Ensure the port is not blocked by a firewall on either the device or the client machine. Confirm the `HttpBridge` server is running on the device.
Choose a different port number when calling `HttpBridge.start(PORT, ...)`. Common alternatives include `8081`, `8082`, or `3000` (though `3000` might conflict with web development servers).
Open your `android/app/src/main/AndroidManifest.xml` file and add `<uses-permission android:name="android.permission.INTERNET" />` just before the `<application>` tag.