jonassiewertsen/statamic-livewire-search
A Statamic addon that brings instant, Livewire-powered search to your site. Index collections and entries, get fast as-you-type results, and drop customizable search components into Antlers templates with minimal setup. Ideal for adding flexible site search without extra infrastructure.
composer require jonassiewertsen/statamic-livewire-search, then immediately open its composer.json and confirm the Livewire constraint. Because the repo is archived, this is the single most important step — the package may target Livewire 2 or 3, and you need to know which before wiring anything up.php artisan vendor:publish and look for a provider tag (usually statamic-livewire-search). This typically exposes the Blade view (and sometimes a config for result limits/index name) so you can edit markup instead of patching vendor files.src/Search.php or similar) and its view under resources/views. Between those two you can see the property name being searched, how results are fetched (almost certainly Statamic\Facades\Search::index(...)->search(...)), and what data the view receives.config/statamic/search.php has an index, then run php please search:update. Without this you get an empty result set and will waste an hour debugging the component.<livewire:search /> (or @livewire('search') on Livewire 2) to your header/nav partial. Confirm @livewireStyles and @livewireScripts are present in your layout — Livewire components silently do nothing without them.First use case: a header search box on a content-heavy marketing site that returns entry titles and URLs as the user types, dropping into a results page or a dropdown. That is the package's entire sweet spot — don't expect faceting, typo tolerance, or relevance tuning out of the box.
App\Livewire\SiteSearch extends \Jonassiewertsen\...\Search and override render() or the query method. Render your component in the layout (<livewire:site-search />), leaving an upgrade path and a clean place to patch behavior if the vendor package ever breaks.aria-live region, wire:key per result, and truncating long excerpts.wire:model.live.debounce.300ms="search" — plain wire:model is deferred and will look broken. Keep the debounce in your published view so it survives component upgrades.EntrySaved / EntryDeleted that calls the search index insert/update (or dispatch php please search:update from a queue job). This is the integration point most people forget; a stale index is indistinguishable from a broken component.$collection property and set it from the parent view (<livewire:site-search collection="blog" />).GET /search form action so no-JS users (and crawlers) still get results. The live dropdown is an enhancement, not the feature.Livewire::test(SiteSearch::class)->set('search', 'foo')->assertSee('Foo Result'). This catches the common breakage where the property name or query method changed.composer.json, and budget for either a fork or a 40-line replacement component using Statamic's Search facade directly. Honestly, the facade version is not much more work and removes the dependency entirely.wire:model vs wire:model.live before debugging anything else.php please search:update and verify from php artisan tinker with Search::index('default')->search('term') before touching the view.config/statamic/search.php, not in the Livewire component.wire:key or the components will fight over state. Same for the input id attribute — duplicate IDs break label/aria-controls wiring.{!! $result->title !!} to highlight matched terms, sanitize with e() or strip_tags() first. The package can't protect you here.searchable fields are all Statamic settings. When something behaves oddly, check config/statamic/search.php and any cached config (php artisan config:clear) before assuming the package is at fault.aria-live="polite"), role="listbox"/option for the dropdown, and Escape-to-close are almost never included. Budget a small sprint for it.How can I help you explore Laravel packages today?