Polling

Livewire offers a directive called wire:poll that, when added to an element, will refresh the component every 5s.

Polling for changes over Ajax is a lightweight, simpler alternative to something like Laravel Echo, Pusher, or any WebSocket strategy.
<div wire:poll>
    Current time: {{ now() }}
</div>

You can customize the frequency by passing a directive modifier like 750ms. For example:

<div wire:poll.750ms>
    Current time: {{ now() }}
</div>

You can also specify a specific action to fire on the polling interval by passing a value to wire:poll:

<div wire:poll="foo">
    Current time: {{ now() }}
</div>

Now, the foo method on the component will be called every 5 seconds.

← Previous Topic

Prefetching

Next Topic →

Loading States