Registry / http-networking / react-native-http-bridge-refurbished

react-native-http-bridge-refurbished

JSON →
library1.2.9jsnpmunverified

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-refurbished
INSTALL
IMPORT
SIG · REACT-NATIVE-HTTP-
R
react-native-http-bridge-refurbished
http-networkingjavascriptv1.2.9
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HttpBridge
import { HttpBridge } from 'react-native-http-bridge-refurbished';
const HttpBridge = require('react-native-http-bridge-refurbished');
This is a named export. CommonJS `require` is generally not recommended for modern React Native projects and may lead to issues with native module loading.
HttpRequest
import type { HttpRequest } from 'react-native-http-bridge-refurbished';
Import the `HttpRequest` type for strong typing of incoming request objects in TypeScript projects. The object typically includes `requestId`, `url`, `method`, `headers`, and `body`.

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.

import React, { useEffect, useState } from 'react'; import { View, Text, Button, Alert, StyleSheet } from 'react-native'; import { HttpBridge, type HttpRequest } from 'react-native-http-bridge-refurbished'; const SERVER_PORT = 8080; const App: React.FC = () => { const [serverStatus, setServerStatus] = useState('Stopped'); const [lastRequest, setLastRequest] = useState<HttpRequest | null>(null); useEffect(() => { // Start the HTTP server HttpBridge.start(SERVER_PORT, true); // true enables console logging setServerStatus(`Running on port ${SERVER_PORT}`); // Register a request handler HttpBridge.onHttpRequest((request: HttpRequest) => { console.log('Received HTTP Request:', request); setLastRequest(request); if (request.url === '/') { HttpBridge.respond( request.requestId, 200, 'application/json', JSON.stringify({ message: 'Hello from React Native HTTP Bridge!' }) ); } else if (request.url.startsWith('/echo')) { const urlObj = new URL(`http://localhost${request.url}`); // Use a dummy base URL to parse parameters const echoMessage = urlObj.searchParams.get('message') || 'No message provided'; HttpBridge.respond( request.requestId, 200, 'text/plain', `Echo: ${echoMessage}` ); } else { HttpBridge.respond( request.requestId, 404, 'text/plain', 'Not Found: Try / or /echo?message=your_text' ); } }); // Cleanup on component unmount return () => { HttpBridge.stop(); setServerStatus('Stopped'); console.log('HTTP Bridge server stopped.'); }; }, []); const handleStopServer = () => { HttpBridge.stop(); setServerStatus('Stopped'); Alert.alert('Server Stopped', `HTTP server on port ${SERVER_PORT} has been stopped.`); }; return ( <View style={styles.container}> <Text style={styles.title}>HTTP Debug Server</Text> <Text style={styles.statusText}>Status: {serverStatus}</Text> <Button title="Stop Server" onPress={handleStopServer} /> {lastRequest && ( <View style={styles.requestBox}> <Text style={styles.requestHeader}>Last Request:</Text> <Text>Method: {lastRequest.method}</Text> <Text>URL: {lastRequest.url}</Text> <Text numberOfLines={1}>Headers: {JSON.stringify(lastRequest.headers)}</Text> <Text numberOfLines={1}>Body: {lastRequest.body || '(empty)'}</Text> </View> )} <Text style={styles.instructions}> Access from browser/client (use your device's IP): `http://[YOUR_DEVICE_IP]:${SERVER_PORT}/` `http://[YOUR_DEVICE_IP]:${SERVER_PORT}/echo?message=Hello` </Text> </View> ); }; const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: 20, backgroundColor: '#f8f8f8', }, title: { fontSize: 26, fontWeight: 'bold', marginBottom: 15, color: '#333', }, statusText: { fontSize: 18, marginBottom: 25, color: '#555', }, requestBox: { marginTop: 30, borderWidth: 1, borderColor: '#ddd', borderRadius: 8, padding: 15, width: '100%', backgroundColor: '#fff', shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.1, shadowRadius: 4, elevation: 3, }, requestHeader: { fontWeight: 'bold', fontSize: 16, marginBottom: 5, color: '#333', }, instructions: { marginTop: 30, fontSize: 14, textAlign: 'center', color: '#777', lineHeight: 20, }, }); export default App;
Debug
Known issues
breakingThis package has a peer dependency on `react-native >=0.72`. Projects using older versions of React Native will likely encounter build or runtime errors and should upgrade `react-native` or use an older, compatible version of this library.
fix
Ensure your project's `react-native` version is `>=0.72` or downgrade `react-native-http-bridge-refurbished` to a compatible version.
affects: <1.0.0
gotchaOlder versions (prior to 1.2.8) experienced Android build issues, which were resolved in versions 1.2.7 and 1.2.8.
fix
Upgrade to `react-native-http-bridge-refurbished@1.2.8` or newer to resolve known Android build stability problems.
affects: <1.2.8
gotchaAn iOS `OS EXC_BAD_ACCESS` crash was fixed in version 1.2.4. Earlier versions might experience instability on iOS.
fix
Upgrade to `react-native-http-bridge-refurbished@1.2.4` or newer to prevent potential iOS crashes.
affects: <1.2.4
gotchaWhen accessing the in-app HTTP server from an external client (browser, Postman, etc.), ensure you use the device's actual IP address, not `localhost` or `127.0.0.1`. Network connectivity and firewall rules may also prevent access.
fix
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.
affects: >=1.0.0
gotchaOn Android, the app's `AndroidManifest.xml` must include the `android.permission.INTERNET` permission for the HTTP server to function correctly and receive network requests.
fix
Add `<uses-permission android:name="android.permission.INTERNET" />` inside the `<manifest>` tag in your `android/app/src/main/AndroidManifest.xml` file.
affects: >=1.0.0
Errors
Common errors & fixes
error: `react-native-http-bridge-refurbished` has not been linked. Please run `npx react-native link react-native-http-bridge-refurbished`.
This package includes native modules for iOS and Android, which require linking to the native projects. While React Native's autolinking usually handles this, sometimes it fails or requires a cache clear.
fix
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`).
Network request failed
This error typically occurs on the client side when attempting to connect to the React Native app's HTTP server. Possible causes include incorrect IP address, an inaccessible port, or a firewall blocking the connection.
fix
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.
Address already in use
The specified port for the HTTP Bridge server is already being used by another application or process on the device.
fix
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).
java.lang.SecurityException: Permission denied (missing INTERNET permission?)
On Android, the application does not have the necessary `INTERNET` permission to open network sockets or accept incoming connections.
fix
Open your `android/app/src/main/AndroidManifest.xml` file and add `<uses-permission android:name="android.permission.INTERNET" />` just before the `<application>` tag.
Upgrade
Version history
1.2.9latest on npm
Audit
Dependencies
react-nativerequiredRequired peer dependency for React Native application integration.
Agent activity
10 hits · last 30 days
node
8
Resources
react-native-http-bridge-refurbished — npm install react-native-http-bridge-refurbished · libregistry