A small Blazor interop library that sets up Microsoft Clarity


Keywords
.net, blazor, c#, clarity, dotnet, interop, csharp
License
MIT
Install
Install-Package Soenneker.Blazor.Clarity -Version 2.1.888

Documentation

Soenneker.Blazor.Clarity

A Blazor interop library that sets up Microsoft Clarity

Installation

dotnet add package Soenneker.Blazor.Clarity

Usage

  1. Register the interop within DI (Program.cs)
public static async Task Main(string[] args)
{
    ...
    builder.Services.AddClarity();
}
  1. Inject IClarityInterop within your App.Razor file
@using Soenneker.Blazor.Clarity.Abstract
@inject IClarityInterop ClarityInterop
  1. Initialize the interop in OnInitializedAsync within App.Razor using your Clarity project key
protected override async Task OnInitializedAsync()
{
    await ClarityInterop.Init("your-key-here");
    ...
}