Photo by James Harrison on Unsplash

WebSockets is a technology that enables your server and your client to keep a connection open and send requests to each other. This is widely used when you need to keep your clients synchronized or to send messages or notifications to all your clients.

Microsoft developed SignalR, which is its technology for developing real-time applications, which are applications where the server can push information to the client instantly. SignalR also has support for the implementation of WebSockets.

Here I’m going to walk you through the creation of a simple real-time chat by having a .NET Core API and a ReactJS application connected and synchronized with SignalR.

Requirements

The Project

Our project will be divided into two projects, one server Web API with .NET Core and one front-end with ReactJS. So let’s create a folder Chatty to hold our whole project.

We’ll start by developing our API.

API

Let’s create our API by navigating to the Chatty folder and creating a new folder called API. Inside this folder run the following command to create a new solution:

dotnet new sln -n Chatty

Now let’s create a new webapi project and add it to our solution with:

dotnet new webapi -o Chatty.Api
dotnet sln add ./Chatty.Api/Chatty.Api.csproj

#web-development #signalr #react #websocket #programming

Creating a simple real-time chat with .NET Core, ReactJS and SignalR
51.25 GEEK