Jul 7, 2025

·

Ismael Santiago

🚫 How to Limit Clicks on Livewire Buttons in Filament v3 (Easy Rate Limiting)

If you use Filament v3 and want to prevent a button from firing a thousand times per minute, I’ll show you how to limit it in 2 steps.

Install the Package

Open your terminal and run:

This package is maintained by the creator of Filament and works perfectly with any Livewire component.

Apply It to Your Method

Suppose you have a custom page and you want to limit a method called generateReport.

Add the WithRateLimiting trait:

<?php
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException;
use Filament\Notifications\Notification;

class GenerateReport extends Page
{
    use WithRateLimiting;

    public function generateReport(): void
    {
        try {
            $this->rateLimit(3); // maximum 3 times per minute
        } catch (TooManyRequestsException $e) {
            Notification::make()
                ->title('Too Many Attempts')
                ->body("Please wait {$e->secondsUntilAvailable} seconds.")
                ->danger()
                ->send();
            return;
        }
    }
}