Search code examples
laravellaravel-livewire

Uncaught ReferenceError: Livewire is not defined using Laravel 8


hope you are doing okay!

I'm using Laravel 8 and I'm getting the error Uncaught ReferenceError: Livewire is not defined please help me with how can I resolve that thank u.

enter image description here

enter image description here \resources\views\livewire\crud-records-livewire.blade.php

          <!DOCTYPE html>
            <html lang="en">
           <head>
            <meta charset="UTF-8">
             <meta name="viewport" content="width=device-width, initial- 
            scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>Document</title>
    @livewireStyles
    </head>
   <body>
    <div style="text-align: center">
        <button wire:click="increment">+</button>
        <h1></h1>
    </div>
      @livewireScripts
  </body>
 </html>

\app\Http\Livewire\CrudRecordsLivewire.php

class CrudRecordsLivewire extends Component
{

    public $count = 0;

    public function increment()
    {
        $this->count++;
    }

    public function render()
    {
            

        return view('livewire.crud-records-livewire');
    }
}


Route::get('/messages',CrudRecordsLivewire::class);

Solution

  • Try to publish frontend assets

    php artisan livewire:publish --assets