MediatR 14.1.0 (original) (raw)

CI NuGet NuGet MyGet (dev)

Simple mediator implementation in .NET

In-process messaging with no dependencies.

Supports request/response, commands, queries, notifications and events, synchronous and async with intelligent dispatching via C# generic variance.

Examples in the wiki.

Installing MediatR

You should install MediatR with NuGet:

Install-Package MediatR

Or via the .NET Core command line interface:

dotnet add package MediatR

Either commands, from Package Manager Console or .NET Core CLI, will download and install MediatR and all required dependencies.

Using Contracts-Only Package

To reference only the contracts for MediatR, which includes:

Add a package reference to MediatR.Contracts

This package is useful in scenarios where your MediatR contracts are in a separate assembly/project from handlers. Example scenarios include:

Registering with IServiceCollection

MediatR supports Microsoft.Extensions.DependencyInjection.Abstractions directly. To register various MediatR services and handlers:

services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblyContaining<Startup>());

or with an assembly:

services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(Startup).Assembly));

This registers:

This also registers open generic implementations for:

To register behaviors, stream behaviors, pre/post processors:

services.AddMediatR(cfg => {
    cfg.RegisterServicesFromAssembly(typeof(Startup).Assembly);
    cfg.AddBehavior<PingPongBehavior>();
    cfg.AddStreamBehavior<PingPongStreamBehavior>();
    cfg.AddRequestPreProcessor<PingPreProcessor>();
    cfg.AddRequestPostProcessor<PingPongPostProcessor>();
    cfg.AddOpenBehavior(typeof(GenericBehavior<,>));
    });

With additional methods for open generics and overloads for explicit service types.

Setting the license key

You can set the license key when registering MediatR:

services.AddMediatR(cfg => 
{
    cfg.LicenseKey = "<license key here>";
})

Or if not using Microsoft.Extensions.DependencyInjection:

Mediator.LicenseKey = "<license key here>";

The license key does not need to be set on client applications (such as Blazor WASM). Turn off the license warning by configuring logging in your logging start configuration:builder.Logging.AddFilter("LuckyPennySoftware.MediatR.License", LogLevel.None);

You can register for your license key at MediatR.io

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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.
.NET Core netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed.
.NET Standard netstandard2.0 is compatible. netstandard2.1 was computed.
.NET Framework net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed.
MonoAndroid monoandroid was computed.
MonoMac monomac was computed.
MonoTouch monotouch was computed.
Tizen tizen40 was computed. tizen60 was computed.
Xamarin.iOS xamarinios was computed.
Xamarin.Mac xamarinmac was computed.
Xamarin.TVOS xamarintvos was computed.
Xamarin.WatchOS xamarinwatchos was computed.

NuGet packages (2.6K)

Showing the top 5 NuGet packages that depend on MediatR:

Package Downloads
MediatR.Extensions.Microsoft.DependencyInjection MediatR extensions for ASP.NET Core 163.7M
MediatR.Extensions.Autofac.DependencyInjection An extension for Autofac-IoC to use MediatR and CQRS with ease. 9.9M
TIKSN-Framework TIKSN Framework is a .NET 10 application framework and utility library for building modular services, command-line tools, data-driven applications, and .NET MAUI apps. It includes dependency injection helpers, Autofac modules, repository, query repository, file repository, stream repository, pagination, unit-of-work abstractions, Entity Framework Core, Azure Table Storage, Azure Blob Storage, MongoDB, LiteDB, and RavenDB adapters, memory, distributed, and hybrid repository cache decorators, finance and money types, pricing models, currency conversion, central-bank foreign exchange providers, globalization, language and region localization resources, JSON, XML, MessagePack, custom binary serialization, Protocol Buffers-backed licensing schema support, license generation and signature services, shell and PowerShell application infrastructure, telemetry abstractions, correlation IDs, settings, known folders, network connectivity, antimalware abstractions, versioning, numbering, time period types, REST helpers, sitemap models, and platform-specific MAUI registrations. 4.4M
Elsa.Core Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application. This package contains the core of Elsa. Tip: reference the `Elsa` package instead of this one. 4.1M
MediatR.Extensions.FluentValidation.AspNetCore MediatR extension to FluentValidation for .NET framework. 4.1M

GitHub repositories (221)

Showing the top 20 popular GitHub repositories that depend on MediatR:

Repository Stars
jasontaylordev/CleanArchitecture Clean Architecture Solution Template for ASP.NET Core 20.2K
kgrzybek/modular-monolith-with-ddd Full Modular Monolith application with Domain-Driven Design approach. 13.8K
dotnet-architecture/eShopOnWeb Sample ASP.NET Core 8.0 reference application, now community supported: https://github.com/NimblePros/eShopOnWeb 10.7K
dotnet/eShop A reference .NET application implementing an eCommerce site 10.6K
MassTransit/MassTransit Distributed Application Framework for .NET 7.8K
ChilliCream/graphql-platform Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Nitro the awesome Monaco based GraphQL IDE. 5.7K
jasontaylordev/NorthwindTraders Northwind Traders is a sample application built using ASP.NET Core and Entity Framework Core. 5.0K
dotnetcore/Util Util是一个.Net平台下的应用框架,旨在提升中小团队的开发能力,由工具类、分层架构基类、Ui组件,配套代码生成模板,权限等组成。 4.6K
simplcommerce/SimplCommerce A simple, cross platform, modulith ecommerce system built on .NET 4.4K
oskardudycz/EventSourcing.NetCore Examples and Tutorials of Event Sourcing in .NET 3.7K
martinothamar/Mediator A high performance implementation of Mediator pattern in .NET using source generators. 3.6K
fullstackhero/blazor-starter-kit Clean Architecture Template for Blazor WebAssembly Built with MudBlazor Components. 3.6K
discord-net/Discord.Net An unofficial .Net wrapper for the Discord API (https://discord.com/) 3.5K
evolutionary-architecture/evolutionary-architecture-by-example Navigate the complex landscape of .NET software architecture with our step-by-step, story-like guide. Unpack the interplay between modular monoliths, microservices, domain-driven design, and various architectural patterns. Go beyond the one-size-fits-all solutions and understand how to blend these approaches based on your unique needs. 3.4K
aspnetrun/run-aspnetcore-microservices Microservices on .NET platforms used ASP.NET Web API, Docker, RabbitMQ, MassTransit, Grpc, Yarp API Gateway, PostgreSQL, Redis, SQLite, SqlServer, Marten, Entity Framework Core, CQRS, MediatR, DDD, Vertical and Clean Architecture implementation with using latest features of .NET 8 and C# 12 3.2K
kgrzybek/sample-dotnet-core-cqrs-api Sample .NET Core REST API CQRS implementation with raw SQL and DDD using Clean Architecture. 3.1K
ErsatzTV/legacy Open-source platform that transforms your personal media library into live, custom TV channels. 2.8K
thepirat000/Audit.NET An extensible framework to audit executing operations in .NET 2.6K
altmann/FluentResults A generalised Result object implementation for .NET/C# 2.6K
vietnam-devs/coolstore-microservices A full-stack .NET microservices build on Dapr and Tye 2.5K

Include prerelease

Include vulnerable

Include deprecated

Version Downloads Last Updated
14.1.0 2,702,222 3/3/2026
14.0.0 2,705,995 12/3/2025
14.0.0-beta-1 6,138 11/20/2025
13.1.0 1,681,510 10/24/2025
13.0.0 3,895,079 7/2/2025
12.5.0 31,781,847 4/1/2025
12.4.1 54,440,398 9/9/2024
12.4.0 10,511,042 7/23/2024
12.3.0 11,918,872 6/6/2024
12.2.0 40,750,464 11/17/2023
12.1.1 23,413,469 7/10/2023
12.0.1 22,691,468 2/23/2023
11.1.0 18,571,018 11/19/2022
11.0.0 25,321,739 9/30/2022
10.0.1 43,588,062 1/10/2022
10.0.0 1,287,771 1/6/2022
9.0.0 73,934,082 10/8/2020