Skip to main content

How broadcasting works

Broadcasting lets your server notify the browser the moment something happens — an order ships, a message arrives, a file finishes processing — without the browser polling for updates. The flow is:
  1. Something happens on the server (a model updates, a job completes).
  2. Your code fires a Laravel event that implements ShouldBroadcast.
  3. Laravel queues a broadcast job and sends the event payload to a WebSocket server.
  4. The browser, connected to the same WebSocket server via Laravel Echo, receives the event and updates the UI.
Broadcasting is built on top of Laravel’s event system. Events and listeners are the foundation — broadcasting adds a delivery channel. Make sure you’re comfortable with events and listeners before continuing.

Setup

Broadcasting is disabled in new Laravel apps. Enable it with:
This creates config/broadcasting.php and routes/channels.php, and prompts you to choose a driver.
Before any events can be broadcast, you need a running queue worker. Broadcasting dispatches jobs asynchronously to avoid slowing down your HTTP responses.

Laravel Reverb

Reverb is Laravel’s official self-hosted WebSocket server, introduced in Laravel 11. It’s the recommended driver for most applications — no external service account required.

Install Reverb

The quickest path installs everything at once:
Or install manually:

Environment variables

Start the Reverb server

In production, manage this process with Supervisor or a similar daemon manager.

Channel types

Creating a broadcast event

Implement ShouldBroadcast on the generated class:
By default, all public properties are included in the broadcast payload. Limit the data with broadcastWith():
Override the event name clients listen for with broadcastAs():
When using a custom name, prefix it with . in JavaScript to bypass Echo’s default namespace:

Authorizing private channels

Private and presence channels require a server-side authorization check before a client can subscribe. Define authorization callbacks in routes/channels.php:
Return true (or any truthy value) to allow the subscription; return false to deny it. The first parameter is always the authenticated user; subsequent parameters match the wildcards in the channel name.

Route model binding in channels

Use the model type instead of an ID and Laravel resolves it automatically:

Channel classes

When your channels.php grows, move authorization logic into dedicated classes:
Register it in routes/channels.php:

Firing broadcast events

Fire a broadcast event the same way you fire any other Laravel event:
Exclude the current user from receiving their own broadcast (useful in chat or collaborative editing):
toOthers() requires the event class to use the InteractsWithSockets trait.

Receiving events with Laravel Echo

Install Echo and set up the client

Configure Echo in resources/js/bootstrap.js:
Build your assets after updating the config:

Listening for events

React and Vue hooks

If you’re using a React or Vue starter kit, Echo ships composable hooks:
The hook unsubscribes automatically when the component unmounts.

End-to-end example: real-time order status

1

Enable broadcasting and start services

2

Create the broadcast event

3

Authorize the channel

4

Fire the event when the order changes

5

Listen for the event in the browser

Verify your VITE_REVERB_* environment variables are set before running npm run build. Vite inlines these values at build time — they won’t be updated by changing .env after the build.

Next steps

Laravel Reverb

Set up and operate the Reverb server: production configuration, Nginx proxying, Supervisor, and horizontal scaling with Redis.

Events and listeners

Broadcasting is built on Laravel’s event system. Learn how to create events and listeners.
Last modified on April 13, 2026