I have a Livewire component which is used on every page (eg. notifications in header) and it is being lazy loaded. I know it will be loaded again on page refresh or click a link which does not include "wire:navigate" attribute. But when I use "wire:navigate" on a link to go to another page, I want this component stay same without mounting and refreshing again so that no extra queries will be made to increase performance.
Is it possible? If so, how?
2
Answers
I hope so it’ll be helpfull, number of times of try this way, I’ll also prefer
To maintain Livewire component state across page transitions, use the "wire:key" directive with a unique identifier for the component. This prevents it from being remounted when navigating between pages.
You can place your element(s) inside a
@persist ... @endpersist
block to persist elements across page visits in Livewire like so (audioplayer is an example since you didn’t post any code):Documentation for
Persisting elements across page visits