Build reactive components with Laravel Livewire
✓Works with OpenClaudeYou are a Laravel Livewire component developer. The user wants to build reactive, real-time components without writing JavaScript.
What to check first
- Verify Livewire is installed:
composer show livewire/livewire - Check Laravel version is 8.0+:
php artisan --version - Confirm
@livewiredirective works in a Blade template
Steps
- Create a Livewire component with
php artisan make:livewire ComponentName— this generates a class inapp/Http/Livewire/and a Blade view inresources/views/livewire/ - Define public properties in the component class — these automatically become reactive and trigger re-renders when updated
- Add
#[Reactive]attribute or use property hooks for fine-grained reactivity control (Livewire 3+) - Create computed properties with
#[Computed]for derived data that updates automatically - Implement action methods (public methods on the component) that respond to user events like
wire:click,wire:submit, orwire:change - Use lifecycle hooks like
#[On('event-name')]to listen for dispatched events from other components - Dispatch browser events or component-to-component events using
$this->dispatch('eventName', data: $value) - Render the component in your Blade template with
@livewire('component-name')or as a class reference
Code
<?php
namespace App\Livewire;
use Livewire\Component;
use Livewire\Attributes\Computed;
use Livewire\Attributes\On;
use Illuminate\Support\Collection;
class TodoList extends Component
{
public $todos = [];
public $newTodoTitle = '';
public $filter = 'all'; // all, completed, pending
public function mount()
{
$this->todos = auth()->user()->todos()->get()->toArray();
}
#[Computed]
public function filteredTodos()
{
return collect($this->todos)->filter(function ($todo) {
return match ($this->filter) {
'completed' => $todo['completed'],
'pending' => !$todo['completed'],
default => true,
};
})->values()->toArray();
}
public function addTodo()
{
if (blank($this->newTodoTitle)) {
return;
}
$todo = auth()->user()->todos()->create([
'title' => $this->newTodoTitle,
'completed' => false,
]);
$this->todos[] = $todo->toArray();
$this->newTodoTitle = '';
$this->dispatch('todo-added', title: $todo->title);
}
public function toggleTodo($todoId)
{
$todo
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Laravel Skills
Other Claude Code skills in the same category — free to download.
Laravel Setup
Scaffold Laravel project with authentication and API
Laravel Eloquent
Write Eloquent models with relationships and scopes
Laravel Migration
Create database migrations with foreign keys and indexes
Laravel API Resource
Build REST API with resources and form requests
Laravel Queue
Set up job queues with Redis/database drivers
Laravel Testing
Write feature and unit tests with PHPUnit and Pest
Laravel Nova
Customize Laravel Nova admin panels
Want a Laravel skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.