PHPackages                             dutchcodingcompany/livewire-recaptcha - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. dutchcodingcompany/livewire-recaptcha

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

dutchcodingcompany/livewire-recaptcha
=====================================

Add Google Recaptcha V3 support to your Laravel Livewire components

v1.1.0(2mo ago)2533.0k↓53.9%11[1 PRs](https://github.com/DutchCodingCompany/livewire-recaptcha/pulls)1MITPHPPHP ^8.2CI passing

Since Jun 4Pushed 2w ago3 watchersCompare

[ Source](https://github.com/DutchCodingCompany/livewire-recaptcha)[ Packagist](https://packagist.org/packages/dutchcodingcompany/livewire-recaptcha)[ Docs](https://github.com/dutchcodingcompany/livewire-recaptcha)[ RSS](/packages/dutchcodingcompany-livewire-recaptcha/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (2)Dependencies (10)Versions (8)Used By (1)

Livewire ReCAPTCHA v3/v2/v2-invisible
=====================================

[](#livewire-recaptcha-v3v2v2-invisible)

[![Latest Version on Packagist](https://camo.githubusercontent.com/093522c26221eae1641c58c8499519ebf7bfb5c6bfe53ebc6e6bd4b68f829bdd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6475746368636f64696e67636f6d70616e792f6c697665776972652d7265636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dutchcodingcompany/livewire-recaptcha)[![GitHub Tests Action Status](https://camo.githubusercontent.com/4e99da4b6f77357295e965e95cb3cb0ed13642978d587b9f32ed466136a410fd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6475746368636f64696e67636f6d70616e792f6c697665776972652d7265636170746368612f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473)](https://github.com/dutchcodingcompany/livewire-recaptcha/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/0730e266b5601fcf97e21935b22663f21acdcf0a5f23581d5bb7a927208ba340/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6475746368636f64696e67636f6d70616e792f6c697665776972652d7265636170746368612f7068702d63732d66697865722e796d6c3f6272616e63683d6d61696e266c6162656c3d7374796c65)](https://github.com/dutchcodingcompany/livewire-recaptcha/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![GitHub PHPStan Action Status](https://camo.githubusercontent.com/cb1e2375a261c906285507d75c5eaf419e7e5f4109ab24ac3e5e3e8560ef3c57/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6475746368636f64696e67636f6d70616e792f6c697665776972652d7265636170746368612f7068707374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d7068707374616e)](https://github.com/DutchCodingCompany/livewire-recaptcha/actions?query=workflow%3APHPStan++branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/73385c74e5e5faddc925e8f36d6c263a8f0697c2ac6350fcefcf0248270f80d0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6475746368636f64696e67636f6d70616e792f6c697665776972652d7265636170746368612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dutchcodingcompany/livewire-recaptcha)

This package provides a custom Livewire directive to protect your Livewire functions with a *Google reCAPTCHA (v2 + v2 invisible + v3)* check.

Installation
------------

[](#installation)

```
composer require dutchcodingcompany/livewire-recaptcha
```

Configuration
-------------

[](#configuration)

Read  on how to create your own key pair for the specific ReCaptcha version you are going to implement.

This package supports the following versions. Note that each version requires a different sitekey/secretkey pair:

**Version****Docs****Notes****v3** (recommended)[V3 Docs](https://developers.google.com/recaptcha/docs/v3)**v3** (enterprise)[V3 Docs](https://developers.google.com/recaptcha/docs/v3)Use `'version' => 'v3-enterprise'`**v2**[V2 Docs](https://developers.google.com/recaptcha/docs/display)**v2 invisible**[V2 Docs](https://developers.google.com/recaptcha/docs/invisible)Use `'size' => 'invisible'`Your options should reside in the `config/services.php` file:

```
    // V3 config:
    'google' => [
        'recaptcha' => [
            'site_key' => env('GOOGLE_RECAPTCHA_SITE_KEY'),
            'secret_key' => env('GOOGLE_RECAPTCHA_SECRET_KEY'),
            'version' => 'v3',
            'score' => 0.5, // An integer between 0 and 1, that indicates the minimum score to pass the Captcha challenge.
            'endpoint' => 'https://www.google.com/recaptcha/api/siteverify', // For enterprise users, fill in your URL from Google Console.
        ],
    ],

    // V2 config:
    'google' => [
        'recaptcha' => [
            'site_key' => env('GOOGLE_RECAPTCHA_SITE_KEY'),
            'secret_key' => env('GOOGLE_RECAPTCHA_SECRET_KEY'),
            'version' => 'v2',
            'size' => 'normal', // 'normal', 'compact' or 'invisible'.
            'theme' => 'light', // 'light' or 'dark'.
        ],
    ],
```

#### Component

[](#component)

In your Livewire component, at your form submission method, add the `#[ValidatesRecaptcha]` attribute:

```
use Livewire\Component;
use DutchCodingCompany\LivewireRecaptcha\ValidatesRecaptcha;

class SomeComponent extends Component
{
    // (optional) Set a response property on your component.
    // If not given, the `gRecaptchaResponse` property is dynamically assigned.
    public string $gRecaptchaResponse;

    #[ValidatesRecaptcha]
    public function save(): mixed
    {
        // Your logic here will only be called if the captcha passes...
    }
}
```

For fine-grained control, you can pass a custom secret key and minimum score (applies only to V3) using:

```
#[ValidatesRecaptcha(secretKey: 'mysecretkey', score: 0.9)]
```

#### View

[](#view)

On the view side, you have to include the Blade directive `@livewireRecaptcha`. This adds two scripts to the page, one for the reCAPTCHA script and one for the custom Livewire directive to hook into the form submission.

Preferrably these scripts are only added to the page that has the Captcha-protected form (alternatively, you can add the `@livewireRecaptcha` directive on a higher level, lets say your layout).

Secondly, add the new directive `wire:recaptcha` to the form element that you want to protect.

```

@if($errors->has('gRecaptchaResponse'))
{{ $errors->first('gRecaptchaResponse') }}
@endif

    Submit

@livewireRecaptcha
```

You can override any of the configuration values using:

```
@livewireRecaptcha(
    version: 'v2',
    siteKey: 'abcd_efgh-hijk_LMNOP',
    theme: 'dark',
    size: 'compact',
)
```

#### Finishing up

[](#finishing-up)

The Google ReCAPTCHA validation will automatically occur before the actual form is submitted. Before the `save()` method is executed, a serverside request will be sent to Google to verify the Captcha challenge. Once the reCAPTCHA response has been successful, your actual Livewire component method will be executed.

#### Error handling

[](#error-handling)

When an error occurs with the Captcha validation, a ValidationException is thrown for the key `gRecaptchaResponse`. There is a translatable error message available under `'livewire-recaptcha::recaptcha.invalid_response'`.

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance91

Actively maintained with recent releases

Popularity40

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~677 days

Total

2

Last Release

82d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/100052?v=4)[Tom Janssen](/maintainers/dododedodonl)[@dododedodonl](https://github.com/dododedodonl)

---

Top Contributors

[![bert-w](https://avatars.githubusercontent.com/u/10498595?v=4)](https://github.com/bert-w "bert-w (22 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")[![ao-jhelmich](https://avatars.githubusercontent.com/u/17061364?v=4)](https://github.com/ao-jhelmich "ao-jhelmich (1 commits)")[![DaniWinter](https://avatars.githubusercontent.com/u/16963641?v=4)](https://github.com/DaniWinter "DaniWinter (1 commits)")[![Webotvorba](https://avatars.githubusercontent.com/u/25526581?v=4)](https://github.com/Webotvorba "Webotvorba (1 commits)")

---

Tags

laravellivewirerecaptcha-v3laravellivewireGoogle ReCaptchadutchcodingcompany

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/dutchcodingcompany-livewire-recaptcha/health.svg)

```
[![Health](https://phpackages.com/badges/dutchcodingcompany-livewire-recaptcha/health.svg)](https://phpackages.com/packages/dutchcodingcompany-livewire-recaptcha)
```

###  Alternatives

[yajra/laravel-datatables-export

Laravel DataTables Queued Export Plugin.

362.2M4](/packages/yajra-laravel-datatables-export)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
