.agents/skills/livewire-development/SKILL.md
Activate this skill when:
Use search-docs for detailed Livewire 3 patterns and documentation.
Use the php artisan make:livewire [Posts\CreatePost] Artisan command to create new components.
These things changed in Livewire 3, but may not have been updated in this application. Verify this application's setup to ensure you follow existing conventions.
wire:model.live for real-time updates, wire:model is now deferred by default.App\Livewire namespace (not App\Http\Livewire).$this->dispatch() to dispatch events (not emit or dispatchBrowserEvent).components.layouts.app view as the typical layout path (not layouts.app).wire:show, wire:transition, wire:cloak, wire:offline, wire:target are available for use.wire:loading and wire:dirty for delightful loading states.@foreach ($items as $item) <div wire:key="item-{{ $item->id }}"> {{ $item->name }} </div> @endforeach
</code-snippet>Prefer lifecycle hooks like mount(), updatedFoo() for initialization and reactive side effects:
public function mount(User $user) { $this->user = $user; } public function updatedSearch() { $this->resetPage(); }
</code-snippet>You can listen for livewire:init to hook into Livewire initialization:
document.addEventListener('livewire:init', function () { Livewire.hook('request', ({ fail }) => { if (fail && fail.status === 419) { alert('Your session expired'); } });
Livewire.hook('message.failed', (message, component) => {
console.error(message);
});
});
</code-snippet>Livewire::test(Counter::class) ->assertSet('count', 0) ->call('increment') ->assertSet('count', 1) ->assertSee(1) ->assertStatus(200);
</code-snippet> <code-snippet name="Testing Livewire Component Exists on Page" lang="php">$this->get('/posts/create') ->assertSeeLivewire(CreatePost::class);
</code-snippet>wire:key in loops causes unexpected behavior when items changewire:model expecting real-time updates (use wire:model.live instead in v3)