Promact.FeatureFlagService.LaunchDarkly
1.0.0
dotnet add package Promact.FeatureFlagService.LaunchDarkly --version 1.0.0
NuGet\Install-Package Promact.FeatureFlagService.LaunchDarkly -Version 1.0.0
<PackageReference Include="Promact.FeatureFlagService.LaunchDarkly" Version="1.0.0" />
<PackageVersion Include="Promact.FeatureFlagService.LaunchDarkly" Version="1.0.0" />
<PackageReference Include="Promact.FeatureFlagService.LaunchDarkly" />
paket add Promact.FeatureFlagService.LaunchDarkly --version 1.0.0
#r "nuget: Promact.FeatureFlagService.LaunchDarkly, 1.0.0"
#:package Promact.FeatureFlagService.LaunchDarkly@1.0.0
#addin nuget:?package=Promact.FeatureFlagService.LaunchDarkly&version=1.0.0
#tool nuget:?package=Promact.FeatureFlagService.LaunchDarkly&version=1.0.0
FeatureFlagService
Generic feature flag service implementation for checking flag state via different providers (PostHog, LaunchDarkly, Unleash).
Usage
IFeatureFlagService lives in the Promact.FeatureFlag namespace (the core package).
using Promact.FeatureFlag;
private IFeatureFlagService _featureFlagService;
public async Task MyMethod()
{
var isEnabled = await _featureFlagService.IsFeatureEnabledAsync("my-feature-flag");
if (isEnabled)
{
// ...
}
}
PostHog
Add nuget package
Promact.FeatureFlagService.PostHog
ASP.NET Core projects
Add below in Program.cs (or Startup.cs inside ConfigureServices)
services.AddPostHogFeatureFlagService(options =>
{
options.ApiKey = configuration["PostHog:ApiKey"];
options.Host = configuration["PostHog:Host"];
options.ProjectId = int.Parse(configuration["PostHog:ProjectId"]);
});
Add relevant appsettings.json values
"PostHog": {
"ApiKey": "",
"Host": "",
"ProjectId": 0
}
Inject IFeatureFlagService in class constructor from where you want to check flags
public MyClass(IFeatureFlagService featureFlagService)
{
...
}
LaunchDarkly
Add nuget package
Promact.FeatureFlagService.LaunchDarkly
ASP.NET Core projects
Add below in Program.cs (or Startup.cs inside ConfigureServices)
services.AddLaunchDarklyFeatureFlagService(options =>
{
options.SdkKey = configuration["LaunchDarkly:SdkKey"];
options.Environment = configuration["LaunchDarkly:Environment"];
});
Add relevant appsettings.json values
"LaunchDarkly": {
"SdkKey": "",
"Environment": ""
}
By default, the per-request LaunchDarkly user context (user key, email, subscription) is built
from well-known claim types on the current HttpContext. If your app uses different claim
types, supply your own factory:
services.AddLaunchDarklyFeatureFlagService(options =>
{
options.SdkKey = configuration["LaunchDarkly:SdkKey"];
options.Environment = configuration["LaunchDarkly:Environment"];
options.UserContextFactory = provider =>
{
var httpContext = provider.GetRequiredService<IHttpContextAccessor>().HttpContext;
return new LaunchDarklyUserContextDetails
{
UserKey = httpContext?.User.FindFirst("sub")?.Value ?? "anonymous",
Email = httpContext?.User.FindFirst("email")?.Value ?? "",
Subscription = httpContext?.User.FindFirst("subscription")?.Value ?? "Basic",
};
};
});
Set options.Offline = true in tests or local development to avoid contacting LaunchDarkly's
servers -- every flag then evaluates to its default value.
Inject IFeatureFlagService in class constructor from where you want to check flags
public MyClass(IFeatureFlagService featureFlagService)
{
...
}
Unleash
Add nuget package
Promact.FeatureFlagService.Unleash
ASP.NET Core projects
Add below in Program.cs (or Startup.cs inside ConfigureServices)
services.AddUnleashFeatureFlagService(options =>
{
options.AppName = configuration["Unleash:AppName"];
options.Environment = configuration["Unleash:Environment"];
options.UnleashApi = configuration["Unleash:APIUrl"];
options.ApiToken = configuration["Unleash:ApiToken"];
});
Add relevant appsettings.json values
"Unleash": {
"AppName": "",
"Environment": "",
"APIUrl": "",
"ApiToken": ""
}
Inject IFeatureFlagService in class constructor from where you want to check flags
public MyClass(IFeatureFlagService featureFlagService)
{
...
}
Unleash also supports subscription-level flag checks, which aren't part of the shared
IFeatureFlagService contract -- inject the concrete UnleashFeatureFlagService directly:
public MyClass(UnleashFeatureFlagService unleashFeatureFlagService)
{
...
}
var isEnabledForSubscription = await unleashFeatureFlagService.IsFeatureForSubscriptionEnabledAsync("my-feature-flag");
By default, the subscription context (user id, subscription level) is built from well-known
claim types on the current HttpContext. Supply your own factory via
options.SubscriptionContextFactory if your app uses different claim types.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- LaunchDarkly.ServerSdk (>= 8.16.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 95 | 7/25/2026 |
| 1.0.0-beta-1.0.0 | 51 | 7/25/2026 |