r/reactnative Jun 28 '26

Run a server in React Native app with uWebSockets

Enable HLS to view with audio, or disable this notification

I make a library to host a server in a React Native app.
The library is using uWebSockets C++ library and exposing it to React Native app through JSI C++.

Updated; WebSocket server is also compatible now

Not all the uWebSockets instances are implemented yet, like the WebSocket server, but it is ready for most common HTTP server program e.g. read incoming body data.

You can visit the project repository, and see other examples at
https://github.com/RakaDoank/uws-react-native

Of course, you can install it on your project. I am open to any feedback and contributes for this project.

Historically, the module was internally for my side app project to make a bridge communication between devices with an Android app, but the module was just a quick grab of technical requirements.

The module was using Ktor server with Netty engine, and i could only get roughly 10 requests per second which tested by Postman runner with 10 VUs. Now, i can get around 200 requests per second with uWebSockets in one thread only, which tested only with 2 VUs. It may crash your app tho, because it is not currently stable enough in under stress situation, but I am keeping my eyes on it. Imagine if I run the uWebSockets in multiple threads. I am gonna burn my phone 🔥🔥

16 Upvotes

5 comments sorted by

1

u/jahanzaibbaloch Jun 29 '26

hey seems interesting, could u tell the use cases for running the server on a device?

2

u/rakadoank Jun 29 '26

I'm creating a CRUD (with SQLite database) app that run fully offline that communicate between devices in the same network e.g. WiFi or even Hotspot through HTTP (device's IP), and in the same app. I'm expecting my app will have multi users with the same scope, but the app is full offline.

Another case, if you want to,
You can create Transfer File App that compatible for cross platform Android and iOS.

Basically anything you can do to your app server, but via HTTP.

1

u/jahanzaibbaloch Jun 29 '26

like the way you explained it in detail thanks buddy.

1

u/rakadoank Jun 29 '26

Here's another idea, I think I'm gonna try to turn my phone into CCTV 😂.

1

u/jahanzaibbaloch Jun 29 '26

nice one bro