Is it possible to navigate through page by navbar without page refresh with Laravel Livewire and AlpineJS?

855 Views Asked by At

I am just wondering whether it's possible to navigate through navigation without any page refresh using Laravel Livewire and AlpineJS? I also want to keep the state of the clicked link of the navbar, so I can change it's color. Thanks

1

There are 1 best solutions below

0
coder_uk On

There is indeed. Livewire v3 has just been released and it includes that ability:

Livewire offers a single page application experience via a simple attribute you can add to links in your application: wire:navigate.

For example:

<nav>
    <a href="/" wire:navigate>Dashboard</a>
    <a href="/posts" wire:navigate>Posts</a>
    <a href="/users" wire:navigate>Users</a>
</nav>

For more, check out:

https://livewire.laravel.com/docs/navigate