In this recipe, we will integrate WebSockets in a React Native application. We are going to create a simple chat app, where we will allow clients to send and receive messages to each other.
In order to support WebSockets on React Native, we need to have a server to handle all the clients that will be connected. The server should be able to broadcast a message when it receives a message from any of the clients.
You can download the code for this recipe; it will contain a
server folder with the code needed to listen and send messages to clients. We need to have the server running before writing any React Native code.
To keep things as simple as possible, we will run our server with ...