OpenFeature.Hosting 2.10.0

Prefix Reserved
There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenFeature.Hosting" Version="2.10.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenFeature.Hosting" Version="2.10.0" />
                    
Directory.Packages.props
<PackageReference Include="OpenFeature.Hosting" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OpenFeature.Hosting --version 2.10.0
                    
#r "nuget: OpenFeature.Hosting, 2.10.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OpenFeature.Hosting@2.10.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OpenFeature.Hosting&version=2.10.0
                    
Install as a Cake Addin
#tool nuget:?package=OpenFeature.Hosting&version=2.10.0
                    
Install as a Cake Tool

OpenFeature.Hosting

NuGet Specification

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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