soenneker.blazor.turnstile

A Blazor interop library for Cloudflare Turnstile

MIT License

Stars
3
Committers
2

Soenneker.Blazor.Turnstile

A Blazor interop library for Cloudflare Turnstile

This library simplifies the integration of Cloudflare Turnstile into Blazor applications, providing access to options, methods, and events. A demo project showcasing common usages is included.

Please refer to the Cloudflare documentation for further details.

Installation

dotnet add package Soenneker.Blazor.Turnstile

1. Add the following to your Startup.cs file

public void ConfigureServices(IServiceCollection services)
{
    services.AddTurnstile();
}

Usage

@using Soenneker.Blazor.Turnstile

<Turnstile @ref="_turnstile" OnCallback="OnCallback" Options="_options" ></Turnstile>

@code{
    private readonly TurnstileOptions _options = new()
    {
        SiteKey = "1x00000000000000000000AA" // Testing key
    };

    private void OnCallback(string token)
    {
        // Send this token to your server for validation
        Logger.LogInformation("OnCallback fired, token: {token}", token);
    }
}

⚠️ While 95%+ of the Cloudflare Turnstile JS has been implemented, there are a few features not yet supported. If you need assistance or want to request a new feature, please open an issue or submit a pull request.