Support the ongoing development of →
posted 4 years ago
Last updated 2 years ago.

jamieconnor liked this thread


Ok, so it is possible to put Echo in a service worker, just import it as you normally would

import Echo from 'laravel-echo';




const echo = new Echo({

broadcaster: 'pusher',

key: process.env.MIX_PUSHER_APP_KEY,

cluster: process.env.MIX_PUSHER_APP_CLUSTER,

encrypted: true


you'll need to tell webpack to compile it as well. Note: it is best to have the service worker compiled to the root directory.

I'm using mix so my webpack.mix.js has this in it

mix.js('resources/js/app.js', 'public/js') .js('resources/js/service-worker.js', 'public') .sass('resources/sass/app.scss', 'public/css');

Last updated 4 years ago.

I don't think you will be able to do what your wanting, because you will find the service worker will become 'activated and stopped' after a few minutes of the site being closed, so it will not be listening for push events.


Sign in to participate in this thread!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.