O'Reilly logo

React Native Cookbook by Crysfel Villa, Stan Bershadskiy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Establishing real-time communications with WebSockets

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.

Getting ready

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required