MediatR is a mediator implementation for .NET that enables in-process messaging with no external dependencies.
The tool solves the problem of decoupling request handlers from their callers by implementing the mediator pattern. It supports request/response, commands, queries, notifications, and events, with both synchronous and asynchronous execution. Dispatching uses C# generic variance to route messages intelligently to their handlers without requiring explicit type registration for each handler variant.
Developers should choose MediatR when building applications that benefit from loose coupling between components, particularly in layered architectures or domain-driven designs. It suits projects where you want to centralize cross-cutting concerns like logging, validation, or exception handling through pipeline behaviors. The tool is especially useful when contracts need to live in separate assemblies from handlers, which is common in API, gRPC, or Blazor projects; a contracts-only package is available for this scenario. The project integrates directly with Microsoft.Extensions.DependencyInjection for straightforward registration in modern .NET applications.
The project maintains active continuous integration with automated testing. Development follows a structured release process with both stable and pre-release versions published to package repositories. The maintainers provide comprehensive documentation through wiki examples and support multiple registration patterns to accommodate different architectural needs. The codebase includes thoughtful features like environment variable-based license key discovery for containerized deployments and logging configuration to suppress license warnings in client applications.