A Blazor interop library for Cloudflare Turnstile
MIT License
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.
dotnet add package Soenneker.Blazor.Turnstile
Startup.cs
filepublic void ConfigureServices(IServiceCollection services)
{
services.AddTurnstile();
}
@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.