FF .NET client SDK for Blazor WebAssembly
Use this README to get started with our Feature Flags (FF) Client SDK for .NET. This guide outlines the basics of getting started with the SDK and provides a full code sample for you to try out. This sample doesn’t include configuration options, for in depth steps and configuring the SDK, for example, disabling streaming or using our Relay Proxy, see the .NET SDK Reference.
ff-dotnet-wasm-client-sdk
allows you to run a Feature Flags client inside a WebAssembly (Wasm) Virtual Machine on a browser. For a detailed overview of Wasm see MDN web docs.
It supports polling, metrics and streaming via Microsoft.AspNetCore.Components.WebAssembly.Http.HttpRequestMessage
and uses a non-threaded design based async/await C# methods and timers for compatibility with the limited .NET APIs available in the VM.
Harness Feature flags provide several .NET SDKs. Broadly speaking a client SDK serves one end user (or target) whereas a server SDK handles many targets. A client SDK typically requires less CPU and network bandwith as they don't process rules locally, so are more suited to web browsers, phone and desktop apps. Server SDKs are designed for server environments, since potentially sensitive rule config is pulled, the SDK API key should be treated as a backend secret and not exposed.
This repository. This is a client SDK - it is designed to run client-side inside the web browser's WebAssembly Virtual Machine. It imports some wasm specific modules for streaming support.
This is a generic .NET C# client SDK designed for desktop and mobule apps via MAUI. See the Github repository
Our server side .NET C# server SDK, designed for server environments. See the Github repository
The library is packaged as multi-target supporting net5.0
, net6.0
, net7.0
and net8.0
.
If building from source you will need .Net 8.0.100 or newer (dotnet --version)
To follow along with our test code sample, make sure you’ve:
- Created a Feature Flag on the Harness Platform called harnessappdemodarkmode
- Created a server SDK key and made a copy of it
Add the sdk using dotnet
dotnet add package ff-dotnet-wasm-client-sdk
Some sample applications are provided to help you test the SDK for the first time.
You will need to create a boolean flag called harnessappdemodarkmode
and have a client API key for the SDK to authenticate. Edit FeatureFlagsContext.cs
and add your client API to _apiKey
.
Make sure you have the WASM workflows installed for your particular development environment. This is not described here but you can find more information from Microsoft at Blazor WebAssembly build tools.
The dotnet watch
command will open up a browser:
cd examples/blazor-wasm
dotnet watch
Also, a small command line version has been provided. This runs from the console. To see full browser integration checkout the Blazor WASM example
cd examples/getting-started
export FF_API_KEY=<your key here>
dotnet run
For further examples and config options, see the Client SDK Reference.
For more information about Feature Flags, see our Feature Flags documentation.
Harness is a feature management platform that helps teams to build better software and to test features quicker.