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

fabiopittol's avatar

How to get current component ID?

I'm probably missing something, but how do I get the Livewire's component ID inside of it, like, printing on the Blade template or on the component's x-init?

I mean, let's say I want to console.log() this unique component ID on it's x-init, how would I do that?

I tried dozens of variations based on what the Livewire 3 docs say, also the v2 docs and a bunch of other people's questions without success.

0 likes
2 replies
diegoanso's avatar

Hi, I dont know if you found the answer but I was having the same issue as you. I found out that you can get the component id by using @this->__id in the blade component. Note the two underscores in front of id.

1 like
markpottom's avatar

$this->getId()

The component $id property If you accessed the component's ID directly via $this->id, you should instead use $this->getId():

$this->id;

$this->getId();

1 like

Please or to participate in this conversation.