Soenneker.Blazor.Turnstile 11.0.3045

Prefix Reserved
dotnet add package Soenneker.Blazor.Turnstile --version 11.0.3045
                    
NuGet\Install-Package Soenneker.Blazor.Turnstile -Version 11.0.3045
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Blazor.Turnstile" Version="11.0.3045" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Blazor.Turnstile" Version="11.0.3045" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Blazor.Turnstile" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Blazor.Turnstile --version 11.0.3045
                    
#r "nuget: Soenneker.Blazor.Turnstile, 11.0.3045"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Blazor.Turnstile@11.0.3045
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Blazor.Turnstile&version=11.0.3045
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Blazor.Turnstile&version=11.0.3045
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Blazor.Turnstile

Renders a Cloudflare Turnstile widget in Blazor and exposes its token, expiration, error, reset, and removal lifecycle.

Installation

dotnet add package Soenneker.Blazor.Turnstile

Registration

using Soenneker.Blazor.Turnstile.Registrars;

builder.Services.AddTurnstileInteropAsScoped();

Render a widget

@using Soenneker.Blazor.Turnstile
@using Soenneker.Blazor.Turnstile.Options

<Turnstile Options="_options"
           OnCallback="HandleToken"
           OnExpiredCallback="HandleExpiration"
           OnErrorCallback="HandleError" />

@code {
    private readonly TurnstileOptions _options = new()
    {
        SiteKey = "your-site-key",
        Action = "sign-in"
    };

    private Task HandleToken(string token)
    {
        if (!string.IsNullOrEmpty(token))
        {
            // Send the token to a trusted server for Siteverify validation.
        }

        return Task.CompletedTask;
    }

    private Task HandleExpiration(string _) => Task.CompletedTask;
    private Task HandleError(string message) => Task.CompletedTask;
}

OnCallback and TokenChanged are raised when a token is issued and again with a cleared value after expiration or an error. OnExpiredCallback and OnErrorCallback provide the corresponding reason. The component's Token and WidgetId properties expose the current values.

The browser token is not proof that a request is legitimate. Send it to a trusted server and validate it with Cloudflare's Siteverify API before performing the protected operation. Keep the Turnstile secret on the server; never include it in Blazor WebAssembly code or browser configuration.

Manual lifecycle

Set ManualCreate = true when application code needs to control widget creation. After the component has rendered, call Create() and retain its returned widget ID. With automatic creation, use Reset() to request another challenge and Remove() to remove the JavaScript widget.

<Turnstile @ref="_turnstile" Options="_manualOptions" />

@code {
    private Turnstile? _turnstile;

    private readonly TurnstileOptions _manualOptions = new()
    {
        SiteKey = "your-site-key",
        ManualCreate = true
    };

    private async Task CreateWidget()
    {
        if (_turnstile is not null)
            await _turnstile.Create();
    }
}

Calling Create() before the component's first render throws InvalidOperationException. Calling it again without first removing the widget returns null. The component disposes its .NET reference when it leaves the render tree; the scoped interop service is owned by dependency injection.

See Cloudflare's client-side rendering documentation for supported widget settings and the Siteverify documentation for server validation.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.3045 0 11/17/2026
11.0.3044 55 11/16/2026
11.0.3043 115 11/16/2026
11.0.3042 73 11/15/2026
11.0.3041 52 11/15/2026
11.0.3040 48 11/15/2026
11.0.3039 60 11/15/2026
11.0.3038 74 11/15/2026
11.0.3036 99 11/15/2026
11.0.3035 53 11/15/2026
11.0.3033 75 11/14/2026
11.0.3031 68 11/14/2026
11.0.3030 442 11/12/2026
11.0.3029 82 11/12/2026
11.0.3028 84 11/12/2026
11.0.3027 88 11/12/2026
11.0.3026 86 11/11/2026
11.0.3025 88 11/11/2026
11.0.3024 76 11/11/2026
11.0.3022 93 11/11/2026
Loading failed

Update dependency Soenneker.Blazor.Utils.ResourceLoader to 11.0.1847 (#4608)