Member-only story

Quickly Create a SPA-Like Experience with wire:navigate in Livewire v3

I Nyoman Jyotisa
3 min readNov 14, 2024

Traditionally, Laravel applications are built with multiple pages, requiring a full page reload whenever users click a link. SPA (Single Page Application), however, avoids this by refreshing only parts of the page, which boosts speed by not reloading JavaScript and CSS assets on every request. This method offers a smoother, more efficient browsing experience.

In this guide, we’ll explore how wire:navigate can provide SPA-like speed without the added complexity of building an API!

Using wire:navigate

Getting started with wire:navigate is simple. Just add it to your links like this:

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

Now, when a link is clicked, Livewire v3 intercepts the request and uses its rapid rendering approach to load the page, making your app feel faster.

Handling Redirects with wire:navigate

Redirecting users within your app is smooth and fast with wire:navigate. Here’s how to redirect from a Livewire component:

return $this->redirect('/posts', navigate: true);

--

--

No responses yet