Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Livewire

Building a Search Component in Livewire v4

Create a real-time search with debouncing.

1 February 20261 min readLivewireاقرأ بالعربية

On this page

  1. Component
  2. Template

Build a performant search component.

Component

php
use Livewire\Attributes\Url;

class SearchProducts extends Component
{
    #[Url]
    public string $query = '';
}

Template

blade
<input type="search" wire:model.live.debounce.300ms="query">
@foreach(Product::search($query)->get() as $p)
    <div>{{ $p->name }}</div>
@endforeach
All articles

Keep reading

  • Authorization in Livewire v4 Components1 February 20261 min read
  • Blaze Pre-Compiler: Massive Performance Gains in Livewire v41 February 20261 min read
  • Building a Bookmark Feature with Livewire v41 February 20261 min read