wire:init
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.
wire:init calls an action after the component has initialized in the browser:
<div wire:init="loadRecommendations">
<?php if ($magewire->ready): ?>
<!-- Render recommendations. -->
<?php else: ?>
<?= $escaper->escapeHtml(__('Loading recommendations…')) ?>
<?php endif ?>
</div>
This creates an additional Magewire request after the initial Magento page response. Use mount() for state required
during the first render, and use lazy loading when an entire expensive component should be
deferred. wire:init is best for optional work that should begin immediately after the page becomes interactive.
Always provide an action expression. In Magewire 3.5, a bare wire:init attribute is read as an empty string and does
not reliably fall back to $refresh.