Substantive.Blazor.Captcha 9.4.0-build20260115r1
Blazor.Captcha
Blazor.Captcha is a .NET 10 Blazor component library for integrating CAPTCHA widgets (Google reCAPTCHA v2/v3 and hCaptcha) into Blazor WebAssembly and Server applications. It provides reusable components, JSInterop adapters, and flexible configuration for secure user validation.
Features
- Google reCAPTCHA v2: Interactive challenge widget.
- Google reCAPTCHA v3: Background risk scoring and badge.
- hCaptcha: Privacy-focused CAPTCHA alternative.
- Blazor-idiomatic API: Use as Razor components with event callbacks.
- Culture, theme, and position customization.
- AOT compatible and supports .NET 10.
- JSInterop adapters for script management and event handling.
- Extensive logging via
ILogger.
Installation
- Add the NuGet package to your project:
dotnet add package Blazor.Captcha
- Register required services in your
Program.cs:
builder.Services.AddBlazorCaptcha();
Usage
Google reCAPTCHA v2
@using Substantive.Blazor.Captcha
<ReCaptchaV2 SiteKey="your-site-key"
OnSuccess="HandleSuccess"
OnExpired="HandleExpired" />
Google reCAPTCHA v3
@using Substantive.Blazor.Captcha
<ReCaptchaV3 SiteKey="your-site-key"
Position="ReCaptchaV3Position.BottomRight"
OnSuccess="HandleSuccess" />
hCaptcha
@using Substantive.Blazor.Captcha
<HCaptcha SiteKey="your-hcaptcha-site-key"
Size="HCaptchaSize.Normal"
OnSuccess="HandleSuccess"
OnExpired="HandleExpired" />
Event Callbacks
OnSuccess: Invoked with the CAPTCHA token when completed.OnExpired: Invoked when the challenge expires.
Resetting Captcha
Each component exposes a ResetCaptcha() method to allow users to retry the challenge.
Configuration
- Culture: Set via the
Cultureparameter (e.g.,"en","fr"). - Theme: Automatically detects dark/light theme for reCAPTCHA v3.
- Position: For reCAPTCHA v3 badge (
BottomRight,BottomLeft,Inline). - Size: For hCaptcha (
Normal,Compact,Invisible).
Advanced
- JSInterop adapters (
ReCaptchaV2JS,ReCaptchaV3JS,HCaptchaJS) can be injected for direct control. - Logging extensions for diagnostics.
- Custom JSON converter for widget IDs.
License
Copyright © United Nations.
MIT License.
Contributing
Contributions and issues are welcome via the repository.
Showing the top 20 packages that depend on Substantive.Blazor.Captcha.
| Packages | Downloads |
|---|---|
|
Substantive.Metapackage.BlazorComponents
A metapackage contains all Blazor components.
|
5 |
|
Substantive.Metapackage.BlazorComponents
A metapackage contains all Blazor components.
|
6 |
|
Substantive.Metapackage.BlazorComponents
A metapackage contains all Blazor components.
|
7 |
|
Substantive.Metapackage.BlazorComponents
A metapackage contains all Blazor essential building blocks. It packed standalone Blazor components and extensions that often use such as Navigation, Exception Handling, Localization, etc,.
|
7 |
.NET 10.0
- Substantive.Blazor.JSInterop (>= 9.4.0-build20260115R1)
- Substantive.ComponentModel.Blazor (>= 9.4.0-build20260115R1)