Configure Laravel Reverb in Filament Broadcasting

Filament comes with native Broadcasting via Echo, but by default, it recommends Pusher. What if you want to use the new Laravel Reverb? Let's see how to do it.

Step 1: Get Your Filament Project Ready

First, we will assume that you already have a Filament project. It doesn't have to be anything special. It can even be an empty project like this:

Step 2: Install Reverb

To install Reverb, you need to run the following command:

php artisan install:broadcasting

This will install all required files and dependencies. We can confirm this by looking at our .env file:

# ...

Step 3: Publish Filament Broadcasting Configuration

Next, we have to publish the Filament configuration file to make it work with Reverb. To do this, run the following command:

php artisan vendor:publish --tag=filament-config

This will create a new file, config/filament.php. Open it and change the broadcasting section to look like this:

// ...
'echo' => [
'broadcaster' => 'reverb',
'key' => env('VITE_REVERB_APP_KEY'),
'cluster' => env('VITE_REVERB_APP_CLUSTER'),
'wsHost' => env('VITE_REVERB_HOST'),
'wsPort' => env('VITE_REVERB_PORT'),
'wssPort' => env('VITE_REVERB_PORT'),
'authEndpoint' => '/broadcasting/auth',
'disableStats' => true,
'encrypted' => true,
'forceTLS' => false,
// ...

Now, what is this? Well, if we look at a deep-dived source code - Filament takes this echo array and passes it to Laravel Echo:


{{-- ... --}}
@if (config('filament.broadcasting.echo'))
<script data-navigate-once>
window.Echo = new window.EchoFactory(@js(config('filament.broadcasting.echo')))
window.dispatchEvent(new CustomEvent('EchoLoaded'))
{{-- ... --}}

Step 4: Test It

Now, we can test if everything works. Open your page in the browser and look at the Inspector. You should see:

This is because we still need to start the Reverb server. To do this, run the following command:

php artisan reverb:start

Now refresh the page, and you should not see any errors. If you don't - congratulations! You have successfully set up Reverb with Filament. From here, you can send out events as usual and react to them in JavaScript like this:

window.addEventListener('DOMContentLoaded', function () {
.listen('SendDeploymentMessageEvent', (event) => {
// Do something with the event

Of course, if you want to do something more complex - here are some resources:

Happy Broadcasting!

Bonus: Check Browser WebSocket Connection

As a bonus, we want to show you how to check if your browser is connected to the WebSocket server. Here are the steps:

  1. In the Inspector, visit the Network tab
  2. Find WS filter
  3. Click on the name of the WebSocket connection
  4. Go to the Messages tab

That's it! You will now see all events coming in or out of your browser.

No comments or questions yet...

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 60 courses (1084 lessons, total 42 h 44 min)
  • 80 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord

Recent Premium Tutorials