Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Pass Parameters to Component

Premium
2 min read

Passing data to a component is a common thing to do. Let's see how we can do that.


When rendering a Livewire component, we can pass a value to a property.

<livewire:create-post title="This is a title" />

Here we pass the initial title to the CreatePost Livewire component. We need to accept this in the components mount lifecycle hook.

class CreatePost extends Component
{
public string $title = '';
 
public function mount(string $title = null): void
{
$this->title = $title;
}
 
// ...
}

The mount method in Livewire is identical to the __construct used in PHP classes.

If you need to pass dynamic values or variables to a...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (29 h 14 min)

You also get:

54 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

No comments yet…

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.