I’m new to Livewire. I learned that Livewire default is to replace state but it seems pushing state. I created the following simple pages, but when I navigate to the second page, I can still see the first page by hitting the browser’s back button. Am I doing something wrong or is this natural behavior of Livewire? Is there any way to prevent this behavior? I want to make it look like a single page application. The previous page should be replaced with the new page in the browser’s history, too. Please advise.
web.php
Route::get('/', First::class);
Route::get('/second', Second::class);
First.php
class First extends Component
{
public function render()
{
return view('livewire.first');
}
}
first.blade.php
<div>
<a href="/second">Navigate to second page</a>
</div>
Second.php
class Second extends Component
{
public function render()
{
return view('livewire.second');
}
}
second.blade.php
<div>Second Page</div>