OpenFeature.Hosting
2.10.0
Prefix Reserved
See the version list below for details.
dotnet add package OpenFeature.Hosting --version 2.10.0
NuGet\Install-Package OpenFeature.Hosting -Version 2.10.0
<PackageReference Include="OpenFeature.Hosting" Version="2.10.0" />
<PackageVersion Include="OpenFeature.Hosting" Version="2.10.0" />
<PackageReference Include="OpenFeature.Hosting" />
paket add OpenFeature.Hosting --version 2.10.0
#r "nuget: OpenFeature.Hosting, 2.10.0"
#:package OpenFeature.Hosting@2.10.0
#addin nuget:?package=OpenFeature.Hosting&version=2.10.0
#tool nuget:?package=OpenFeature.Hosting&version=2.10.0
OpenFeature.Hosting
OpenFeature.Hosting is an extension for the OpenFeature .NET SDK that streamlines integration with .NET applications using dependency injection and hosting. It enables seamless configuration and lifecycle management of feature flag providers, hooks, and evaluation context using idiomatic .NET patterns.
๐งช The OpenFeature.Hosting package is still considered experimental and may undergo significant changes. Feedback and contributions are welcome!
๐ Quick Start
Requirements
- .NET 8+
- .NET Framework 4.6.2+
Installation
Add the package to your project:
dotnet add package OpenFeature.Hosting
Basic Usage
Register OpenFeature in your application's dependency injection container (e.g., in Program.cs for ASP.NET Core):
builder.Services.AddOpenFeature(featureBuilder => {
featureBuilder
.AddInMemoryProvider();
});
You can add global evaluation context, hooks, and event handlers as needed:
builder.Services.AddOpenFeature(featureBuilder => {
featureBuilder
.AddContext((contextBuilder, serviceProvider) => {
// Custom context configuration
})
.AddHook<LoggingHook>()
.AddHandler(ProviderEventTypes.ProviderReady, (eventDetails) => {
// Handle provider ready event
});
});
Domain-Scoped Providers
To register multiple providers and select a default provider by domain:
builder.Services.AddOpenFeature(featureBuilder => {
featureBuilder
.AddInMemoryProvider("default")
.AddInMemoryProvider("beta")
.AddPolicyName(options => {
options.DefaultNameSelector = serviceProvider => "default";
});
});
Registering a Custom Provider
You can register a custom provider using a factory:
builder.Services.AddOpenFeature(featureBuilder => {
featureBuilder.AddProvider(provider => {
// Resolve services or configuration as needed
return new MyCustomProvider();
});
});
๐งฉ Features
- Dependency Injection: Register providers, hooks, and context using the .NET DI container.
- Domain Support: Assign providers to logical domains for multi-tenancy or environment separation.
- Event Handlers: React to provider lifecycle events (e.g., readiness).
- Extensibility: Add custom hooks, context, and providers.
๐ ๏ธ Example: ASP.NET Core Integration
Below is a simple example of integrating OpenFeature with an ASP.NET Core application using an in-memory provider and a logging hook.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenFeature(featureBuilder => {
featureBuilder
.AddInMemoryProvider()
.AddHook<LoggingHook>();
});
var app = builder.Build();
app.MapGet("/", async (IFeatureClient client) => {
bool enabled = await client.GetBooleanValueAsync("my-flag", false);
return enabled ? "Feature enabled!" : "Feature disabled.";
});
app.Run();
If you have multiple providers registered, you can specify which client and provider to resolve by using the FromKeyedServices attribute:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenFeature(featureBuilder => {
featureBuilder
.AddInMemoryProvider("default")
.AddInMemoryProvider("beta")
.AddPolicyName(options => {
options.DefaultNameSelector = serviceProvider => "default";
});
});
var app = builder.Build();
app.MapGet("/", async ([FromKeyedServices("beta")] IFeatureClient client) => {
bool enabled = await client.GetBooleanValueAsync("my-flag", false);
return enabled ? "Feature enabled!" : "Feature disabled.";
});
app.Run();
๐ Further Reading
๐ค Contributing
Contributions are welcome! See the CONTRIBUTING guide for details.
| Product | Versions 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 was computed. 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. |
-
.NETFramework 4.6.2
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- OpenFeature (>= 2.10.0)
- System.Collections.Immutable (>= 8.0.0)
- System.Threading.Channels (>= 8.0.0)
- System.ValueTuple (>= 4.6.1)
-
.NETStandard 2.0
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- OpenFeature (>= 2.10.0)
- System.Collections.Immutable (>= 8.0.0)
- System.Threading.Channels (>= 8.0.0)
-
net8.0
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- OpenFeature (>= 2.10.0)
-
net9.0
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.0)
- OpenFeature (>= 2.10.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on OpenFeature.Hosting:
| Package | Downloads |
|---|---|
|
OpenFeature.Contrib.Providers.Flagd
flagd provider for .NET |
|
|
OpenFeature.Providers.Ofrep
OFREP provider for .NET |
|
|
OpenFeature.Providers.MultiProvider
OpenFeature is an open standard for feature flag management, created to support a robust feature flag ecosystem using cloud native technologies. OpenFeature will provide a unified API and SDK, and a developer-first, cloud-native implementation, with extensibility for open source and commercial offerings. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.11.0 | 67 | 12/18/2025 |
| 2.10.0 | 6,735 | 12/1/2025 |
| 2.9.0 | 12,741 | 10/16/2025 |
| 2.8.1 | 30,876 | 7/31/2025 |
| 2.8.0 | 974 | 7/30/2025 |
| 2.7.0 | 22,321 | 7/3/2025 |
| 2.6.0 | 23,514 | 5/23/2025 |
| 2.5.0 | 24,036 | 4/28/2025 |
| 2.4.0 | 6,733 | 4/14/2025 |
| 2.3.2 | 10,775 | 3/27/2025 |
| 2.3.1 | 7,782 | 2/4/2025 |
| 2.3.0 | 20,845 | 1/31/2025 |
| 2.2.0 | 62,587 | 12/12/2024 |
| 2.1.0 | 1,198 | 11/18/2024 |