Skip to content

wire:click

Laravel Livewire Documentation Reference

Since Magewire is heavily inspired by Laravel Livewire, many concepts are either identical or very similar. To avoid duplicating documentation, this page only covers Magewire-specific and platform-specific details. For all general concepts and in-depth explanations, you can refer to the corresponding Laravel Livewire documentation.

Livewire Reference

Use wire:click to call a public component method when an element is clicked:

view/frontend/templates/magewire/counter.phtml
<button type="button" wire:click="increment">
    <?= $escaper->escapeHtml(__('Increase')) ?>
</button>

Arguments can be passed in the expression, but they originate in browser-controlled markup. Resolve sensitive entities again on the server and authorize the action instead of trusting an ID because it appeared in the template.

<button type="button" wire:click="remove(42)">Remove</button>

Event modifiers such as .prevent, .stop, .once, and .debounce are handled through Alpine. Refer to the Livewire 3 page for the complete modifier syntax. Combine the action with wire:loading when the control needs visible pending state.