Skip to content

soenneker/soenneker.blazor.clarity

Repository files navigation

Soenneker.Blazor.Clarity

A Blazor interop library that sets up Microsoft Clarity

Installation

dotnet add package Soenneker.Blazor.Clarity

Usage

  1. Insert the script in wwwroot/index.html at the bottom of your <body> but before the other scripts
<script src="_content/Soenneker.Blazor.Clarity/clarity.js"></script>
  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");
    ...
}

About

A small Blazor interop library that sets up Microsoft Clarity

Topics

Resources

License

Stars

Watchers

Forks