kv.

SwiftDispatch: A Free MediatR Alternative for .NET

Looking for a MediatR alternative? I built SwiftDispatch with source-generated dispatch, Native AOT support, and an MIT license for personal and commercial use.

  • .NET
  • MediatR
  • SwiftDispatch
  • Source Generators
  • Native AOT
  • Open Source

I built SwiftDispatch, a free, lightweight MediatR alternative for .NET, because I wanted a simple mediator library with a straightforward open-source license and Native AOT support.

Why I wanted a MediatR alternative

MediatR’s licensing change made me rethink using it in my projects. I preferred an MIT-licensed option that I could use freely in personal and commercial applications. That was the main reason I started SwiftDispatch.

Source generation and Native AOT

It also gave me a chance to take a different technical approach: C# source generators. SwiftDispatch generates registration and dispatch code at compile time, avoiding reflection-based handler discovery at runtime.

It supports Native AOT and trimming on .NET 8 and .NET 10, with the goal of keeping runtime overhead low.

Moving from MediatR to SwiftDispatch

The familiar patterns are still there: requests, handlers, notifications, streams, and pipeline behaviors. Core interfaces such as IMediator, IRequest, and IRequestHandler should feel familiar to MediatR users.

For the supported features, migration starts with updating namespaces to SwiftDispatch.Contracts and replacing service registration. The SwiftDispatch quick start shows the setup.

If you’re looking for an open-source MediatR alternative, explore the SwiftDispatch documentation or check out SwiftDispatch on GitHub.

← All articles