SignalR is a powerful library by Microsoft that enables real-time communication between server and client applications. It allows you to push data instantly to connected clients without needing them to refresh or repeatedly call the server.
In this article, we’ll cover:
What is SignalR?
Why use SignalR in .NET Core APIs
Step-by-step integration guide
A working code example
Useful external references
🧠 What is SignalR?
ASP.NET Core SignalR simplifies adding real-time web functionality to your applications. It uses WebSockets under the hood (and falls back to other techniques like Server-Sent Events or Long Polling if necessary).
Real-time web functionality means that server code can push content to connected clients instantly as it happens — perfect for chat apps, live dashboards, notifications, or collaborative editing.
⚡ Why Use SignalR with a .NET Core API?
Traditional APIs work on a request-response model. Clients must call the API repeatedly to get updates.
With SignalR, your API can notify clients instantly whenever data changes — reducing latency, bandwidth, and backend load.
Use cases
Live notifications (e.g., messages, alerts, stock updates)
Real-time dashboards (IoT, monitoring, etc.)
Collaborative apps (document editing, gaming)
Background job progress updates
🛠 Step-by-Step: Integrating SignalR in .NET Core API
🧩 Step 1. Create a .NET Core Web API Project
dotnet new webapi -n SignalRDemoAPI
cd SignalRDemoAPI
⚙️ Step 2. Install SignalR NuGet Package
dotnet add package Microsoft.AspNetCore.SignalR
🧱 Step 3. Create a Hub Class
Create a new folder Hubs and add a file NotificationHub.cs:
using Microsoft.AspNetCore.SignalR;
using System.Threading.Tasks;
namespace SignalRDemoAPI.Hubs
{
public class NotificationHub : Hub
{
public async Task SendMessage(string user, string message)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
}
}
🧩 Explanation
Hubacts as a connection point between the server and the client.The
SendMessagemethod broadcasts a message to all connected clients.
🪄 Step 4. Configure SignalR in Program.cs
using SignalRDemoAPI.Hubs;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddSignalR(); // Add SignalR service
var app = builder.Build();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapHub<NotificationHub>("/notifyHub");
});
app.Run();
🧠 Here we:
Registered SignalR service using
AddSignalR().Mapped the
NotificationHubto/notifyHubendpoint.

Join the conversation! Your thoughts help the community grow.