SignalR Overview

Get to know how SignalR can help build responsive interactive apps.

SignalR is a .NET library for building interactive web applications that enable two-way communication between the server and clients. It simplifies the process of adding real-time web functionality to applications by handling the low-level details of managing connections between clients and servers.

By using SignalR, developers can create applications that enable server-side code to push content to connected clients instantly as events occur, rather than relying on the traditional request-response model. It supports various transports, including WebSockets, Server-Sent Events (SSE), and Long Polling.

SignalR can be used in a variety of scenarios, such as chat applications, real-time dashboards, live data updates, collaborative editing, gaming applications, and more. It's a powerful tool for creating interactive, real-time experiences on the web.

SignalR project structure

The following playground contains an application with both the SignalR server and client components:

using Microsoft.AspNetCore.SignalR;

namespace DemoApp;

public class DemoHub : Hub
{
    public async Task BroadcastMessage(string message)
    {
        await Clients.All.SendAsync("ReceiveMessage", message);
    }
}
SignalR hub with a JavaScript client

If we launch this application, here is what we will see on the home page once it is built:

Press + to interact
SignalR client web page
SignalR client web page

We can type a message in the text box that is delivered ...