I think it should be (https://laravel-livewire.com/docs/2.x/events#from-js)
<script>
Livewire.on('createdLink', () => {
alert(1);
});
</script>
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi everyone,
I'm using the TALL stack to create a website.
I have this code in my Livewire component:
<script>
$wire.on('createdLink', () => {
alert(1);
});
</script>
And this is my PHP code:
$this->emit('createdLink');
Here I'm loading in the scripts (in the head section):
<livewire:scripts />
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/turbolinks/5.2.0/turbolinks.js"></script>
<script src="https://cdn.jsdelivr.net/gh/livewire/[email protected]/dist/livewire-turbolinks.js" data-turbolinks-eval="false"></script>
But when I load the page I get this error in my console:
Uncaught ReferenceError: $wire is not defined
Does anyone know what's happening here? I searched about it but couldn't find anything useful.
Thank you! Jeroen
Please or to participate in this conversation.