Hyphen

.NET

Integrate Hyphen's services, including Toggle feature flags, into your .NET applications using the native .NET SDK. Learn about installation, authentication, and initialization.

The Hyphen.Sdk is Hyphen's native .NET SDK. It integrates with the standard .NET host builder and dependency injection so you can use Hyphen services — including Toggle feature flags — across your application.

Table of Contents

Installation

dotnet add package Hyphen.Sdk

Authentication

The SDK authenticates with your project public key and application id. See Get a Project's Public Key for where to find these in the Hyphen dashboard.

Initialization

Register the Toggle service with the host builder and configure your credentials:

builder.Services.AddToggle();

builder.Services.Configure(options =>
{
    options.ProjectPublicKey = "public_your_public_key";
    options.ApplicationId = "your_application_id";
    options.Environment = "production";
});

Usage

Inject the IToggle service and evaluate a flag:

public class MyService
{
    private readonly IToggle _toggle;

    public MyService(IToggle toggle)
    {
        _toggle = toggle;
    }

    public async Task<bool> IsEnabledAsync()
    {
        var result = await _toggle.Evaluate<bool>("your-toggle-key");
        return result.Value ?? false; // fall back to a default when null
    }
}

See also