News

Integrate Cloudflare Turnstile into Laravel and Livewire

Published
Integrate Cloudflare Turnstile into Laravel and Livewire image

Want to integrate Cloudflare Turnstile CAPTCHA into your Laravel or Livewire app? This package from Ryan Chandler makes integration super simple.

Cloudflare Turnstile for Laravel Usage

Include the Turnstile scripts using the @turnstileScripts Blade directive in the <head> of your layout file.

<html>
<head>
@turnstileScripts()
</head>
<body>
{{ $slot }}
</body>
</html>

After that, use the <x-turnstile /> component inside a <form>:

<form action="/" method="POST">
<x-turnstile />
 
<button>
Submit
</button>
</form>

Use the provided validation rule on the server to validate the CAPTCHA response.

use Illuminate\Validation\Rule;
 
public function submit(Request $request)
{
$request->validate([
'cf-turnstile-response' => ['required', Rule::turnstile()],
]);
}

Cloudflare Turnstile with Livewire

This package can also integrate seamlessly with Livewire. Upon successful validation, the property specified inside of wire:model will be updated with the Turnstile token.

<x-turnstile wire:model="yourModel" />

Check out the package on GitHub for more details on customizing and integrating it into your app.

Eric L. Barnes photo

Eric is the creator of Laravel News and has been covering Laravel since 2012.

Filed in

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
Image Dominant Color and HEIC Support in Laravel 13.24 image

Image Dominant Color and HEIC Support in Laravel 13.24

Read article
Official Laravel Zed Extension: LSP for PHP & Blade image

Official Laravel Zed Extension: LSP for PHP & Blade

Read article
Laravel Head: Manage Meta Tags, Open Graph, and JSON-LD image

Laravel Head: Manage Meta Tags, Open Graph, and JSON-LD

Read article
PhpStorm 2026.2 Released image

PhpStorm 2026.2 Released

Read article
Laravel Doctor: Diagnose Your App With One Artisan Command image

Laravel Doctor: Diagnose Your App With One Artisan Command

Read article
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article