Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kenean50's avatar

How to create a global search component with Inertia and React

I wanted a quick search on my navbar area which is globally accessible from all pages.

I tried putting my search method on the shared data like below and tried to do a partial reload whenever there is a search query from any page but it didn't work.

Is this not possible to do with inertia or is there any other way to implement this kind of feature?

   public function share(Request $request): array
   {
        return array_merge(parent::share($request), [
            'quickSearch' => fn () => $this->quickSearch($request)
        ]);
    }
Inertia.visit(curruntUrl, { search: 'John' }, { only: ['quickSearch'] })
0 likes
3 replies
kenean50's avatar

@vincent15000 am using scout with meilisearch of course, my problem is sending the search request globally from any page and getting the results on that same page without redirecting to another search page.

1 like
vincent15000's avatar

@kenean50 Ok sorry I can't help you for this, not sufficient knowledge with InertiaJS. Someone else will help you soon ;).

1 like

Please or to participate in this conversation.