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

vincent15000's avatar

Uncaught ReferenceError: $wire is not defined

Hello,

I have done exactly like in the documentation.

https://livewire.laravel.com/docs/alpine#sharing-state-using-wireentangle

I have this code.

<section
    class="w-full space-y-4"
    x-data="{
        chartsCount: 2,
        activeChart: $wire.entangle('activeChart'),

        toggle(chartToActivate) {
            this.activeChart = chartToActivate;
        },
    }"
>

And I get this error.

Uncaught ReferenceError: $wire is not defined

Can you help me solve this problem, please ?

Thanks.

V

0 likes
14 replies
Sinnbeck's avatar

Is this code in the main components view file or a different blade file?

Did you try this.$wire ?

1 like
vincent15000's avatar

Hello @Sinnbeck, how are you ? ;)

Hmmm ... Yes I tried this.$wire and it doesn't work better.

This code is in the blade view of the Livewire component.

Sinnbeck's avatar

@vincent15000 Doing well. Just decided to help out a bit again :)

Which version are you using. Are you doing any loading of alpine yourself in app.js or in a script tag ?

1 like
vincent15000's avatar

@Sinnbeck I'm using Livewire v3 and AlpineJS and the Livewire scripts are loaded automatically.

In some pages, I only need AlpineJS without Livewire, if I don't load AlpineJS in the app.js file, it doesn't work.

In some other pages, I need Livewire and in these pages I can use AlpineJS without loading it.

So yes I'm loading AlpineJS, but I have tried without loading it and it doesn't work better.

Sinnbeck's avatar

@vincent15000 Are you able to share the full blade file? I cant really figure it out by what is provided so far :)

1 like
Sinnbeck's avatar

Or make a test component with just a single div with x-data and $wire and see if the issue is there also :)

1 like
vincent15000's avatar

@Sinnbeck

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@vincent15000 Really weird. I did some googling and most cases are due to alpine being loaded twice..

1 like
vincent15000's avatar

@Sinnbeck I had already removed the AlpineJS, but it didn't work. And now I don't understand why, but effectively I have removed AlplineJSonce again in the app.js file and it works.

So I have a new question : how is it possible to use AlpineJS in standard blade files (without Livewire) and without loading AlpineJS ?

I ask for this because AlpineJS is loaded with Livewire.

Sorry I reformulate : I is it possible to deactivate AlpineJS in a Livewire component, but not outside a Livewire component ?

vincent15000's avatar

@Sinnbeck Oh I read this page, but too fast. I thought it was @livewireScripts and not @livewireScriptConfig.

vincent15000's avatar

@Sinnbeck The documentation just omits to say that it's necessary to set 'inject_assets' => false, in the livewire configuration file.

Yes it works ;).

1 like

Please or to participate in this conversation.