DEV Community

Using laravel-echo with Nuxt.js

Hiram on April 26, 2020

Hi devs, last day I was trying to configure my Nuxt.js client so it can consume public and private channels from my backend which is built with Lar...
Collapse
 
mankarsandesh profile image
Sandesh Mankar

how to listen to the event in NUXT (SSR Mode). can you give one example? Thanks in Advance

Collapse
 
eichgi profile image
Hiram

I am afraid I haven't use the SSR Mode with nuxt, or at least I didn't know. But please share your resolution when you got it!

Collapse
 
mankarsandesh profile image
Sandesh Mankar

Yeah, I found Solutions for both modes.
follow my Repo.
Nuxt SSR mode: github.com/mankarsandesh/nuxt-sock...
Nuxt SPA mode: github.com/mankarsandesh/nuxt-sock...

Thanks

Thread Thread
 
eichgi profile image
Hiram

Amazing!

Thread Thread
 
kp profile image
KP • Edited

@mankarsandesh thanks for sharing! by chance could you share the laravel side of this? An end to end example would be really helpful to me.

Thread Thread
 
eichgi profile image
Hiram

For backend channeling authentication you would have to specify that you are using Laravel sanctum like this, given I am using the api prefix I put this in routes/api.php:

Broadcast::routes(['middleware' => ['auth:sanctum']]);

And taking this route as example it should works:

Broadcast::channel('App.User.{id}', function ($user, $id) {
    return (int)$user->id === (int)$id;
});

I hope this is the answer you were looking for

Thread Thread
 
kp profile image
KP

@eichgi I’ll have to give it a go - thanks for responding!

Collapse
 
mohammadsaadati profile image
Mohammad Saadati

hi
where can i find the list of all configuration options of laravel echo?

Collapse
 
eichgi profile image
Hiram

Hi Mohammad, in Laravel Docs oficial site you can find basically all the configuration options: laravel.com/docs/8.x/broadcasting#...

Maybe you can find more options inspecting the library itself, sadly I don't know where else to search.

Collapse
 
elinardo10 profile image
elinardo10

is necessary a file of laravel-echo-server? thanks