A modern, extensible, and high-performance .NET library for clean CQRS applications.
NexMediator is a clean, modular, and pluggable mediator engine for .NET 8+ applications — a robust alternative to MediatR with:
- ✅ Built-in pipeline behaviors (logging, validation, caching, transactions)
- 📣 Parallel notifications
- 📡 Async streaming with
IAsyncEnumerable<T> - 🧩 Full DI support and testable architecture
- ⚡ Compiled delegates (no runtime reflection)
Inspired by CQRS, Clean Architecture and DDD.
Install via CLI:
dotnet add package NexMediatorOr via NuGet:
NuGet\Install-Package NexMediatorbuilder.Services.AddNexMediator();This registers the core engine and auto-discovers all handlers.
You can add any of the built-in behaviors:
builder.Services.AddNexMediator(options =>
{
options.AddBehavior(typeof(LoggingBehavior<,>), 1);
options.AddBehavior(typeof(FluentValidationBehavior<,>), 2);
options.AddBehavior(typeof(CachingBehavior<,>), 3);
options.AddBehavior(typeof(TransactionBehavior<,>), 4);
});| Behavior | Description |
|---|---|
LoggingBehavior<,> |
Logs execution details and correlation ID |
FluentValidation<,> |
Validates using FluentValidation |
CachingBehavior<,> |
Adds response-level caching support |
TransactionBehavior<,> |
Wraps command in transaction scope |
🧩 Want to customize? You can implement your own
INexPipelineBehavior<TRequest, TResponse>
and register it with any order:
options.AddBehavior(typeof(MyCustomBehavior<,>), 99);📚 Complete guides, examples and usage patterns available in the Wiki:
👉 https://github.com/vagnerjsmello/NexMediator/wiki
Includes:
- Core concepts (requests, handlers, notifications, streams)
- Usage with Minimal APIs
- Real-world example: AuctionBoardGame
- Custom behaviors, caching, transactions
- Error handling, correlation ID, tests
We welcome contributions!
Star ⭐ the repo, suggest improvements, or submit PRs via feature/* branches.
✅ Use Conventional Commits
📦 Follow our branch strategy: main, develop, feature/*
Apache 2.0 License — free for commercial and open source use.
© 2024–2025 Vagner Mello
🔗 LinkedIn
.NET • C# • CQRS • Mediator • Open Source • NuGet • Clean Architecture • Pipeline • Notifications • Streaming • Validation • Transactions • TDD • DDD
""
