Registry / networking / react-native-nitro-http-server

react-native-nitro-http-server

JSON →
library1.9.2jsnpmunverified

A high-performance HTTP server for React Native, built on Rust's Actix-web framework and integrated via Nitro Modules for native async FFI calls. Version 1.9.2 supports iOS and Android, offering features like static file serving, WebSocket, file upload, URL rewriting, and directory listing. It provides TypeScript-friendly APIs with zero-copy Rust bindings, streaming request/response bodies, and a plugin system (WebDAV, Zip mount). Actively maintained on GitHub by iwater, with a release cadence of about monthly updates. Differentiators: Rust-based performance vs JS-based alternatives, direct FFI without bridge overhead, and compatibility with Node.js http module API.

npm install react-native-nitro-http-server
INSTALL
IMPORT
SIG · REACT-NATIVE-NITRO
R
react-native-nitro-http-server
networkingjavascriptv1.9.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

HttpServer
import { HttpServer } from 'react-native-nitro-http-server'
import HttpServer from 'react-native-nitro-http-server'
Default export is not available; it's a named export. Common mistake: assuming default export.
StaticServer
import { StaticServer } from 'react-native-nitro-http-server'
const StaticServer = require('react-native-nitro-http-server')
CommonJS require will get the whole module, not the named export. Use destructuring.
AppServer
import { AppServer } from 'react-native-nitro-http-server'
const server = new require('react-native-nitro-http-server').AppServer()
Easier to use ESM import syntax. TypeScript types are included.
HttpRequest
import type { HttpRequest } from 'react-native-nitro-http-server'
Type import example. HttpRequest is not exported as a value, only as a type.

Shows creating an HttpServer, starting on a random port (0), handling a request with JSON response, and logging the actual port.

import { HttpServer } from 'react-native-nitro-http-server'; const server = new HttpServer(); async function startServer() { const port = await server.start(0, async (request) => { console.log(`Received: ${request.method} ${request.path}`); return { statusCode: 200, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ message: 'Hello!', path: request.path }), }; }); console.log(`Server running on http://localhost:${port}`); } startServer().catch(console.error);
Debug
Known issues
gotchaThe server must be stopped before the app goes to background or the process exits to avoid resource leaks.
fix
Call `await server.stop()` in app lifecycle hooks (e.g., AppState 'background' listener).
affects: all
gotchaOn iOS, you must run `pod install` after installing the npm package.
fix
Run `cd ios && pod install` in your project root.
affects: all
gotchaThe port passed to `start()` is a hint; the actual port might be different (especially when passing 0). Always use the returned value.
fix
Use `const actualPort = await server.start(0, handler);` and use `actualPort` instead of assuming the input port.
affects: all
gotchaHTTPS is not supported; only HTTP.
fix
Use a reverse proxy if HTTPS is needed.
affects: all
gotchaThe plugin system (WebDAV, Zip, etc.) requires additional installation steps not covered in basic setup.
fix
Refer to plugin documentation in the repository for specific installation and configuration.
affects: >=1.0
Errors
Common errors & fixes
Cannot find module 'react-native-nitro-http-server'
Package not installed or not linked correctly.
fix
Run `npm install react-native-nitro-http-server` and ensure `react-native-nitro-modules` is also installed.
TypeError: server.start is not a function
Importing incorrectly, e.g., using default import instead of named import.
fix
Use `import { HttpServer } from 'react-native-nitro-http-server'` (curly braces).
Error: Unable to resolve module react-native-nitro-http-server
Metro bundler cannot find the module; package may not be installed or cached.
fix
Run `npm install` and `npx react-native start --reset-cache`.
Invariant Violation: Native module 'NitroHttpServer' is not available
The native module has not been loaded; possibly missing pod install or Android autolinking issue.
fix
For iOS: run `cd ios && pod install`. For Android: ensure `react-native-nitro-modules` is properly linked (autolinking should work).
Upgrade
Version history
1.9.2latest on npm
Audit
Dependencies
react-nativerequiredPeer dependency required for React Native runtime
react-native-nitro-modulesrequiredCore dependency providing the Nitro bridge for native module integration
Agent activity
13 hits · last 30 days
node
12
Resources
react-native-nitro-http-server — npm install react-native-nitro-http-server · libregistry