Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Livewire Rate Limiting

Livewire Rate Limiting Laravel Package

danharrin/livewire-rate-limiting

Add rate limiting to Laravel Livewire actions with a simple trait/middleware-style API. Throttle clicks, form submits, and other events to prevent spam and brute force attempts. Configure limits, decay, and messages per component or action.

View on GitHub
Deep Wiki
Context7

Apply rate limiters to Laravel Livewire actions.

Frequently asked questions about Livewire Rate Limiting
How do I add rate limiting to a Livewire action like `submitForm()`?
Use the `RateLimited` trait or the `withRateLimiting()` helper. For example, wrap your action with `withRateLimiting('submit-form', fn() => ['maxAttempts' => 5, 'decaySeconds' => 10])` to limit attempts to 5 per 10 seconds. The package integrates directly with Laravel’s rate-limiting system.
Does this package work with Livewire 2.x or only Livewire 3.x?
This package is officially designed for Livewire 3.x. If you’re using Livewire 2.x, you may need to upgrade or check for compatibility issues, as Livewire 3.x introduced optimizations that align better with the package’s architecture.
Can I set different rate limits per user, IP, or role?
Yes, the package supports granular rate limiting. Use Laravel’s rate-limit keys (e.g., `Cache::tags()`) to scope limits by user, IP, or role. For example, `RateLimiter::for('submit-form')->by($user->id)->response()` enforces per-user limits.
What happens when a user exceeds the rate limit? Can I customize the response?
By default, the package throws a `TooManyRequestsException`, which Livewire converts to a 429 HTTP response. To customize the UI response, catch the exception in your component or extend the package to return a user-friendly message, like a retry button or queue notification.
Will this package slow down my Livewire components if overused?
The package is lightweight and only adds overhead when rate-limiting is active. For high-traffic actions, ensure your cache backend (e.g., Redis) is optimized. If Redis becomes a bottleneck, consider sharding or using a dedicated cache instance for rate-limiting keys.
How do I test rate-limiting logic in my Livewire components?
Use Laravel’s `RateLimiter` facade in unit tests to mock rate-limit responses. For Livewire-specific edge cases (e.g., concurrent actions), write integration tests that simulate rapid clicks or form submissions. The package works seamlessly with Laravel’s testing tools.
Can I use this with Laravel’s queue system to delay rate-limited requests?
Yes, you can combine this package with Laravel queues. When a user hits a rate limit, return a response that suggests retrying later or queue the action for processing. For example, dispatch a job with `dispatch(new ProcessAction($data))->delay(now()->addMinute())` in your component.
What cache driver does this package require, and can I use database-based caching?
The package works with any Laravel-supported cache driver, but Redis is recommended for production due to its speed and atomic operations. Database caching is possible but may introduce latency or contention under high load. Avoid file-based caching for rate-limiting.
Are there alternatives to this package for Livewire rate limiting?
For Livewire-specific rate limiting, this package is the most tailored solution. Alternatives include Laravel’s built-in `throttle` middleware (for HTTP routes) or custom middleware that checks rate limits before Livewire actions, but these require more manual setup and lack Livewire’s action-level granularity.
How do I monitor rate-limit events or log abuses in production?
Extend the package by listening to Laravel events like `illuminate.events.attempting` or log rate-limit hits manually using `Log::channel('abuse')->info()`. For metrics, integrate with Laravel Horizon or Prometheus by publishing custom rate-limit events or using cache tags to track hits.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai