In this episode, we're setting up Laravel Echo to work with our Soketi server for real-time event broadcasting in our Laravel app. We start off with a backend endpoint that broadcasts events and a client ready to listen—but we need a cleaner, more robust way to handle this on the frontend, and that's where Laravel Echo comes in.
We'll head over to the bootstrap.js
file and uncomment the Laravel Echo setup code. Then, we'll install the necessary libraries (laravel-echo
and pusher-js
) with npm, rebuild our assets, and start customizing our Echo configuration. Since we want to use our own Soketi server instead of Pusher's hosted service, we tweak our .env
to add config values for the WebSocket host and port, and then update Echo's settings to use those. We also clean up the config, making sure we aren’t unintentionally sending stats to Pusher, and define which transports (WebSockets) to use.
Finally, for the frontend demo, we inject the basic Echo connection right into our dashboard page with vanilla JavaScript, just to make sure everything works as expected. We set up a quick event listener to console log when the page loads—just a test before moving on to more complex event handling next episode. By the end of this video, you'll have Laravel Echo talking to Soketi and be ready to start handling public channel events on the frontend!