PHPackages                             elvisblanco1993/livewire-v4-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. elvisblanco1993/livewire-v4-recaptcha

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

elvisblanco1993/livewire-v4-recaptcha
=====================================

Add Google reCAPTCHA (v3, v2, invisible) support to Laravel Livewire v4 components

v1.0.0(3mo ago)078MITPHPPHP ^8.2

Since Mar 6Pushed 3mo agoCompare

[ Source](https://github.com/elvisblanco1993/livewire-v4-recaptcha)[ Packagist](https://packagist.org/packages/elvisblanco1993/livewire-v4-recaptcha)[ Docs](https://github.com/elvisblanco1993/livewire-v4-recaptcha)[ RSS](/packages/elvisblanco1993-livewire-v4-recaptcha/feed)WikiDiscussions development Synced 3w ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

Livewire ReCAPTCHA v3 / v2 / v2 Invisible
=========================================

[](#livewire-recaptcha-v3--v2--v2-invisible)

A lightweight package that adds **Google reCAPTCHA protection to Livewire components** using a simple directive and attribute.

This package supports:

- Google **reCAPTCHA v3**
- Google **reCAPTCHA v2**
- Google **reCAPTCHA v2 Invisible**
- **Laravel**
- **Livewire v3 and Livewire v4**

Developed and maintained by **Code Wize Technologies LLC**.

---

Installation
============

[](#installation)

```
composer require elvisblanco1993/livewire-v4-recaptcha

```

---

Configuration
=============

[](#configuration)

Read Google's documentation to create your reCAPTCHA keys:

Each version requires its **own site key and secret key pair**.

---

Supported Versions
------------------

[](#supported-versions)

VersionDocumentationNotes**v3 (recommended)**Score-based verification**v2**Standard checkbox**v2 Invisible**Use `'size' => 'invisible'`---

Laravel Configuration
=====================

[](#laravel-configuration)

Add the configuration to **config/services.php**

reCAPTCHA v3
------------

[](#recaptcha-v3)

```
'google' => [
    'recaptcha' => [
        'site_key' => env('GOOGLE_RECAPTCHA_SITE_KEY'),
        'secret_key' => env('GOOGLE_RECAPTCHA_SECRET_KEY'),
        'version' => 'v3',
        'score' => 0.5,
    ],
],

```

`score` must be between **0 and 1** and determines the minimum trust threshold.

---

reCAPTCHA v2
------------

[](#recaptcha-v2)

```
'google' => [
    'recaptcha' => [
        'site_key' => env('GOOGLE_RECAPTCHA_SITE_KEY'),
        'secret_key' => env('GOOGLE_RECAPTCHA_SECRET_KEY'),
        'version' => 'v2',
        'size' => 'normal',
        'theme' => 'light',
    ],
],

```

Available options:

```
size: normal | compact | invisible
theme: light | dark

```

---

Usage
=====

[](#usage)

Livewire Component
------------------

[](#livewire-component)

Add the `#[ValidatesRecaptcha]` attribute to the method that processes the form.

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

class ContactForm extends Component
{
    public string $gRecaptchaResponse;

    #[ValidatesRecaptcha]
    public function submit()
    {
        // This only runs if the captcha passes
    }
}

```

If the `$gRecaptchaResponse` property is not declared, it will be **automatically created**.

---

Advanced Configuration
----------------------

[](#advanced-configuration)

You can override the secret key or score directly:

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

```

This is useful if you want **different captcha strictness per form**.

---

Blade Usage
===========

[](#blade-usage)

Add the Livewire Directive
--------------------------

[](#add-the-livewire-directive)

Attach the directive to the form you want protected.

```

        Submit

```

---

Add the Script Directive
------------------------

[](#add-the-script-directive)

Add the Blade directive once on the page:

```
@livewireRecaptcha

```

You can add it:

- in the **layout**
- or **only on pages with forms**

---

Error Handling
--------------

[](#error-handling)

When verification fails, a validation error is thrown for:

```
gRecaptchaResponse

```

Example:

```
@if ($errors->has('gRecaptchaResponse'))

        {{ $errors->first('gRecaptchaResponse') }}

@endif

```

The translation key is:

```
livewire-recaptcha::recaptcha.invalid_response

```

---

Overriding Settings in Blade
============================

[](#overriding-settings-in-blade)

You can override any configuration directly:

```
@livewireRecaptcha(
    version: 'v2',
    siteKey: 'your_site_key',
    theme: 'dark',
    size: 'compact'
)

```

---

How It Works
============

[](#how-it-works)

1. The form is submitted.
2. The `wire:recaptcha` directive intercepts the request.
3. A **reCAPTCHA token is generated client-side**.
4. The token is **validated server-side against Google**.
5. If validation passes, the Livewire method runs.

If validation fails, the request is rejected.

---

Compatibility
=============

[](#compatibility)

PackageSupportedLaravel10+Livewirev3Livewirev4---

Security
========

[](#security)

Always validate reCAPTCHA **server-side**, which this package does automatically.

Never trust client responses alone.

---

License
=======

[](#license)

MIT License

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance79

Regular maintenance activity

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

113d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c93ba8e14756d81c321ad795f1edb58b036dcbabf0d46cc0764d849e723dfe3a?d=identicon)[elvisblanco1993](/maintainers/elvisblanco1993)

---

Top Contributors

[![elvisblanco1993](https://avatars.githubusercontent.com/u/15078412?v=4)](https://github.com/elvisblanco1993 "elvisblanco1993 (17 commits)")[![bert-w](https://avatars.githubusercontent.com/u/10498595?v=4)](https://github.com/bert-w "bert-w (9 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")[![ao-jhelmich](https://avatars.githubusercontent.com/u/17061364?v=4)](https://github.com/ao-jhelmich "ao-jhelmich (1 commits)")

---

Tags

laravelrecaptchalivewireGoogle ReCaptchalivewire4Code Wize Technologies

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[timehunter/laravel-google-recaptcha-v3

Laravel Package for google reCAPTCHA v3

2821.0M1](/packages/timehunter-laravel-google-recaptcha-v3)[dutchcodingcompany/livewire-recaptcha

Add Google Recaptcha V3 support to your Laravel Livewire components

2531.4k3](/packages/dutchcodingcompany-livewire-recaptcha)[yajra/laravel-datatables-export

Laravel DataTables Queued Export Plugin.

352.1M4](/packages/yajra-laravel-datatables-export)[timehunter/laravel-google-recaptcha-v2

Laravel Package for google reCAPTCHA v2

1399.8k](/packages/timehunter-laravel-google-recaptcha-v2)[mostafaznv/recaptcha

Laravel package for Google Recaptcha v3

2128.0k](/packages/mostafaznv-recaptcha)[tomshaw/electricgrid

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

119.2k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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