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

Minhazul18's avatar

Livewire's wire:navigate issue

Hey There! I'm using Livewire v3 in my application and want to use a new navigate feature, but it doesn't work as expected! some parts of my application like icon,CSS and js are not working after navigate to a new page via wire:navigate

0 likes
24 replies
Minhazul18's avatar

yes, in the master layout, I've a nav layout called navbar and so sidebar.

those are working but some parts of them not working such as some buttons. I think there could be a DOM issue cause after refreshing the URL, they working fine!

azharazziz's avatar

i have the same problem. Am I have wrong way or something wrong with wire:navigate?

Minhazul18's avatar

I amazed! Why Community don't help us when many of us suffering from the same issue?

thinkverse's avatar

@Minhazul18 probably because not one of you who are having this issue is providing ANY code or reproduction of the issue.

We can't pluck what the issue is out of thin air, we don't know how your code is structured. It's difficult to provide a potential solution when there's nothing to work with.

1 like
TedCod's avatar

I am also facing the same problem, my button with wire:click isn't working properly, but it's works, when I remove the wire:navigate. I am still looking for the solution too

TedCod's avatar

this is the code for my navigation:

    <div class="adm_nav_container">
        <div class="admin_nav_child">
            <x-admin.adm-nav-link :href="route('Manage Users')" :status="request()->routeIs('Manage Users')||request()->routeIs('User Details')" wire:navigate>
                {{ __('Manage Users') }}
            </x-admin.adm-nav-link>
        </div>
        <div class="admin_nav_child">
            <x-admin.adm-nav-link :href="route('Admin Dashboard')" :status="request()->routeIs('Admin Dashboard')" wire:navigate >
                {{ __('Admin Dashboard') }}
            </x-admin.adm-nav-link>
        </div>
    </div>

and this is my button code:

<div class="flex-row search-container no-select container-full mar-1rem p-relative d-flex d-center">
        <span>
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
                <path
                    d="M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z" />
            </svg>
        </span>
        <input class="search-input container-full d-flex" type="text" name="query" wire:model.live.debounce.500ms="query"
            placeholder="Search for ID or Name" max="255" min="0">
        <button wire:click.prevent="resetSearchbar">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
                <path
                    d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z" />
            </svg>
        </button>
    </div>

this is the livewire for resetSearchBar function

<?php

namespace App\Livewire\Admin;

use App\Models\Role;
use App\Models\User;
use Livewire\Component;
use Livewire\WithPagination;
use Illuminate\Support\Benchmark;
use Livewire\Attributes\Js;
use Livewire\Attributes\On;

class ManageUsers extends Component
{

    use WithPagination;

    public $query = '';

				//other code

    public function resetSearchbar()   {
        $this->reset('query');
    }
				//other code
internetservices's avatar

@Minhazul18 This does not work on my side, the page shows temporarily without any CSS then a few seconds later it displays the css.

faizan101010's avatar

May be this will help anyone but my code was not running properly so I added a tiny timeout and then executed my code and that worked. Another thing is the "data-navigate-once" tag that I added. Before this my event listeners were stacking and were firing multiple times in a single navigate

<script data-navigate-once>
    document.addEventListener('livewire:navigated', () => {
        setTimeout(function(){
           //Code here
        }, 1);
    });
</script>
2 likes
dev_ip's avatar

I have the same problem and nothing you have shared and I have seen online has worked for me. I have a template called Minia that includes everything (js, tailwind, jetstream, livewire). However, when I add the wire:navigate to some link, it takes me to the view without loading the page and it works but the template gets completely misconfigured. It seems that livewire conflicts with the js files and styles, leaving the page almost blocked. The only functional are some href, and the rest is not working, ie is almost 100% blocked, but if I do the same exercise in a new project without loading any js, etc., the wire:navigate works perfectly without causing conflicts.

It should be noted that the console does not show me any error.

//sidebar.blade.php
//here I have the wire:navigate
<li>
	<a wire:navigate href="{{ url('starter') }}" >Starter Page</a>
</li>
//master.blade.php
//here I have the main layout where I add the styles and livewire scripts.
<!DOCTYPE html>
<html lang="en" dir="ltr">

<head>
    <meta charset="utf-8" />
    <title>@yield('title') | Minia - Laravel 10 & TailwindCss Admin & Dashboard Template</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <meta content="Tailwind Admin & Dashboard Template" name="description" />
    <meta content="" name="Themesbrand" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <!-- App favicon -->
    <link rel="shortcut icon" href="{{ URL::asset('build/images/favicon.ico') }}" />
    <!-- css files -->
    @include('layouts.head-css')
    <!-- Styles -->
    @livewireStyles
</head>

<body data-mode="light" data-sidebar-size="lg" class="group">
    <!-- sidebar -->
    @include('layouts.sidebar')
    <!-- topbar -->
    @include('layouts.topbar')
    <!-- content -->
    @yield('content')
    <!-- rtl-ltr -->
    @include('layouts.customizer')
    <!-- script -->
    @include('layouts.vendor-scripts')
    <!-- Scripts -->
    @vite(['resources/js/app.js'])
    @livewireScripts
</body>
</html>

I have tried everything with the official documentation and nothing. I have done all this: https: //livewire.laravel.com/docs/installation

'inject_assets' => false,

Also all this: https: //livewire.laravel.com/docs/navigate#javascript-hooks Also all this: https: //livewire.laravel.com/docs/navigate#dont-rely-on-domcontentloaded

But nothing has worked for me.

Help please, I want and need to use wire:navigate in this template. I have checked the 21 questions similar to mine here in the forum and none of them worked for me.

dev_ip's avatar

I contacted the support of the template I am using (minia) and they informed me that it is not feasible to use the wire:navigate in the template because it causes conflicts with the libraries and js files that they have. I'll have to start from scratch with a cleaner template. Thank you all.

Prasyah's avatar

I solved this issue based on this documentation: #manually-bundling-livewire-and-alpine

How to make it run perfectly?

  1. Just open your livewire.php in config folder, then set the 'inject_assets' to false,
  2. Add the wire:navigate to your blade:
  3. Open your app.js, then import this livewire package: import { Livewire } from "../../vendor/livewire/livewire/dist/livewire.esm";
  4. Still on app.js, add this script:
document.addEventListener("livewire:navigated", () => {
    console.log("Navigated");
    Livewire.start();
});
  1. Optional! If you have the custom js script on your app layout head, add this line: 'data-navigate-track'
  2. Do not forget to read the documentation
johnmsykes's avatar

@Prasyah Hi - Your solution was MONEY - Thank you!!

The key bit is your small snippet of JS to go into the app.js file, e.g., defer the Livewire.start() until livewire:navigated via the Event Listener.

Also, in order to use the app.js edits for manually bundling, you must install these assets using npm:

npm install @ryangjchandler/alpine-clipboard

sawal123's avatar

this work ///' '///

=>color-modes.js

document.addEventListener("livewire:navigated", () => { // Get all dark-light switchers console.log("color mode js"); var switchers = document.querySelectorAll(".dark-light-switcher");

// Function to update icons and theme
function updateTheme(isDarkMode) {
    switchers.forEach(function (switcher) {
        var darkIcon = switcher.querySelector(".ri-sun-line");
        var lightIcon = switcher.querySelector(".ri-contrast-2-line");

        if (isDarkMode) {
            lightIcon.style.display = "none";
            darkIcon.style.display = "block";
        } else {
            lightIcon.style.display = "block";
            darkIcon.style.display = "none";
        }
    });

Please or to participate in this conversation.