In this video we are going to learn about Livewire Route.
So lets see how can create livewire route.
First of all lets create a new component.
So switch to the command prompt and just type her the command for creating component.


php artisan make:livewire Home


Now just open the home component view
Inside the this file lets add some text here


<h1>This is Home Component</h1>


Now go to the web.php file and here lets create the route for the component.


Route::get('/home',Home::class);



Now lets check, So switch to the browser and go to the url.
http://localhost:8000/home
And you can see the component.
Now lets see how can we pass parameter to the route.
For adding the parameter inside the route add here {} and inside the curly brackert add the parameter name lets say paramete name is name.

Route::get('/home{name}',Home::class);


Now get this parameter to the component class file.
Inside the this Home component class file
Lets create a property here.


public $name;


Now add here mount lifecycle hook method.
Mount is hook method which is executed before the rendering the view.
So for adding the mount hook just write here


public function mount($name)
{
$this->name = $name;        
}


Now lets display the parameter value to the component view So just write here.


Hello {{$name}}


Now save this file and lets check this.
So switch to browser and in url just add the parameter so just type any name here.
http://localhost:8000/home/john
And here you can see the name.
Alright, now lets see how can we pass the optional parameter.
For that just go web.php.
And inside the route just add here {name?} question mark.
Now go to the component class file and inside the mount lifecycle hook argument just add here $name = null as following.


public function mount($name=null)
{
$this->name = $name;        
}

Now parameter becomes optional parameter.
Now lets check. Just remove the name from url and you can see the component still showing.
And if add the name here its showing the name.
So in this way we can create Livewire Route.