https://github.com/soenneker/soenneker.blazor.clarity
A Blazor interop library that sets up Microsoft Clarity
https://github.com/soenneker/soenneker.blazor.clarity
blazor clarity csharp dotnet interop
Last synced: 2 months ago
JSON representation
A Blazor interop library that sets up Microsoft Clarity
- Host: GitHub
- URL: https://github.com/soenneker/soenneker.blazor.clarity
- Owner: soenneker
- License: mit
- Created: 2023-01-03T01:40:17.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2026-04-22T01:28:55.000Z (2 months ago)
- Last Synced: 2026-04-22T01:33:29.189Z (2 months ago)
- Topics: blazor, clarity, csharp, dotnet, interop
- Language: C#
- Homepage: https://soenneker.com
- Size: 1.96 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/Soenneker.Blazor.Clarity/)
[](https://github.com/soenneker/soenneker.blazor.clarity/actions/workflows/publish-package.yml)
[](https://www.nuget.org/packages/Soenneker.Blazor.Clarity/)
[](https://github.com/soenneker/soenneker.blazor.clarity/actions/workflows/codeql.yml)
#  Soenneker.Blazor.Clarity
### A Blazor interop library that sets up [Microsoft Clarity](https://clarity.microsoft.com/)
## Installation
```
dotnet add package Soenneker.Blazor.Clarity
```
## Usage
1. Register the interop within DI (`Program.cs`)
```csharp
public static async Task Main(string[] args)
{
...
builder.Services.AddClarityInteropAsScoped();
}
```
2. Inject `IClarityInterop` within your `App.Razor` file
```csharp
@using Soenneker.Blazor.Clarity.Abstract
@inject IClarityInterop ClarityInterop
```
3. Call the interop from `OnAfterRenderAsync` in `App.razor`.
```csharp
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender)
return;
await ClarityInterop.Init("your-key-here");
}
```