BlazorChat 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package BlazorChat --version 1.0.0
                    
NuGet\Install-Package BlazorChat -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BlazorChat" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BlazorChat" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="BlazorChat" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BlazorChat --version 1.0.0
                    
#r "nuget: BlazorChat, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BlazorChat@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BlazorChat&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=BlazorChat&version=1.0.0
                    
Install as a Cake Tool

BlazorChat

A drop-in, embeddable real-time chat component for Blazor applications.

BlazorChat is designed to be a lightweight, yet feature-rich, chat solution that can be easily integrated into any Blazor Server or Blazor WebAssembly application. It delegates persistence, broadcasting, and presence to a host-provided service, allowing for flexible backend implementations.

Key Features

  • Real-time Messaging: Built for instant message delivery.
  • Backend Agnostic: Pluggable backend via the IChatService interface.
  • In-Memory Provider: Includes a basic in-memory service for quick demos and testing.
  • Message Reactions: Users can react to messages with emojis.
  • Typing Indicators: Shows when other users are typing.
  • Active User Presence: Displays a count and list of active users in the thread.
  • Message Editing & Deletion: Users can edit or delete their own messages.
  • Reply to Message: Provides context for conversations.
  • Customizable Styling: Easily theme the widget using CSS variables or choose from presets.
  • Accessible: Designed with ARIA attributes and keyboard navigation in mind.

Getting Started

Installation

First, add the BlazorChat NuGet package to your Blazor project.

dotnet add package BlazorChat

Backend Service Configuration

The ChatWidget requires a backend service that implements the IChatService interface. You can use the provided in-memory service for demos or a SignalR-based service for production.

Option 1: In-Memory Service (For Demos)

For quick setup and testing, you can use the built-in InMemoryChatService. This service works within a single server instance.

In your Program.cs, register it as a singleton:

// Program.cs 
	using BlazorChat.Services;

// ... other services 
	builder.Services.AddSingleton<IChatService, InMemoryChatService>();

Note: The InMemoryChatService is for demonstration purposes only. For any real multi-user application, a robust SignalR backend is required.

To unlock the full potential of BlazorChat in a scalable, multi-user production environment, we offer BlazorChat.Server.

BlazorChat.Server is a pre-built, enterprise-ready SignalR backend designed to work seamlessly with the BlazorChat component. It saves you significant development time and provides a fully implemented, persistent, and scalable chat service right out of the box.

Benefits of BlazorChat.Server:

  • Instant Setup: No need to build or maintain your own chat backend.
  • Database Persistence: Pre-configured to save and retrieve message history.
  • Scalable Architecture: Built to handle a large number of concurrent users.
  • Authentication Ready: Easily integrates with your existing authentication system.
  • Professionally Supported: Receive dedicated support for your chat implementation.

Skip the hassle of backend development. **Learn more and purchase BlazorChat.Server at www.loneworx.com **.

Add the Component to a Page

Once your service is configured (either the demo InMemoryChatService or the production BlazorChat.Server), embed the ChatWidget in any Razor component. The component will automatically create its own SignalRChatService instance if one is not injected.

@page "/my-chat"

<ChatWidget ThreadId="project-alpha-general" 
            ChatSender="@currentUser" 
            HubUrl="/chathub" 
            ThreadTitle="Project Alpha Chat" />

@code 
{ 
    private ChatSender currentUser = new() { Id = "user123", 
                                             DisplayName = "Sam Wilson", 
                                             AvatarUrl = "https://i.pravatar.cc/150?img=11" }; 
}

Component Parameters

Parameter Type Description
ThreadId string Required. A unique identifier for the conversation thread.
ChatSender ChatSender Required. An object representing the current user sending messages.
HubUrl string The URL of the SignalR hub. Defaults to /chathub.
AutoCreateChatService bool If true (default), the component creates its own SignalRChatService if an IChatService is not injected via DI.
ThreadTitle string A title to display in the chat header.
CaptionText string Optional text that overrides the ThreadTitle in the header.
ThemePreset ChatThemePreset Selects a built-in theme (e.g., Default, Dark, Teams, Slack).
CustomTheme ChatTheme A custom theme object to override the preset.
WidgetWidth / Height string Sets the dimensions of the chat widget (e.g., "500px", "100%").
BubbleBackgroundMine string CSS color for the current user's message bubbles.
BubbleBackgroundOther string CSS color for other users' message bubbles.

Customization

You can customize the look and feel of the chat widget by overriding the available CSS variables. Apply these styles in your global stylesheet.

/* Example: In your app.css */ 

:root { 
    --blazor-chat-bubble-background-mine: #007bff; 
    --blazor-chat-bubble-color-mine: white; 
    --blazor-chat-bubble-background-other: #f1f1f1; 
    --blazor-chat-bubble-color-other: #333; 
    --blazor-chat-border-radius: 12px; 
}




Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 33 2/28/2026
1.0.2 34 2/24/2026
1.0.1 32 2/24/2026
1.0.0 39 2/24/2026