Client Usage

Next, all that remains is to listen for the event in your JavaScript application. We can do this using Laravel Echo. First, we'll use the channel method to subscribe to the channel. Then, we may use the listen method to listen for the event. By default, all of the event's public properties will be included on the broadcast event:

<script>
    Echo.channel('channelName')
        .listen('MessageSentEvent', (e) => {
            console.log(e.message);
        });
</script>

}}

Last updated