github.com/jbogard/MediatR ↗
Simple, unambitious mediator implementation in .NET
Open this visualization on its own page →
Contributors
64
Lines of Code
2,030
From
2014-03-03
To
2020-12-25
About jbogard/MediatR
MediatR is a lightweight mediator library for .NET that implements the mediator pattern for in-process messaging without external dependencies. It enables developers to decouple request handlers from their callers by routing messages through a central dispatcher, supporting multiple messaging patterns including request/response, commands, queries, notifications, and events with both synchronous and asynchronous execution.
The library uses C# generic variance for intelligent message dispatching and integrates seamlessly with Microsoft's dependency injection abstractions. Installation is straightforward via NuGet, and MediatR provides flexible registration options for handlers, behaviors, stream handlers, and exception handlers within the service collection. A contracts-only package is available separately, allowing projects to reference only the core interfaces without the full implementation, which is particularly useful for scenarios like API contracts, gRPC definitions, and Blazor applications.
MediatR is designed for .NET developers building applications that benefit from loose coupling and separation of concerns. It's especially popular in domain-driven design and CQRS architectures where command and query separation is desired. The project includes examples and documentation in its wiki, and recently introduced a commercial licensing model with optional license key registration for enhanced features.