Using Reverb in Laravel 11: Real-Time Broadcasting Simplified
Real-time applications are becoming essential across many domains — from chats and notifications to live dashboards. Laravel 11 introduces Reverb, a built-in WebSocket server that eliminates the need for third-party services like Pusher or Laravel Echo Server. In this blog, we’ll explore how to use Reverb in Laravel 11, its purpose, setup steps, and why it's a game-changer for real-time broadcasting.
What is Reverb in Laravel?
Reverb is Laravel’s native WebSocket server introduced in Laravel 11. It allows you to broadcast events in real time using WebSockets — without setting up external infrastructure.
With Reverb:
- You don’t need Laravel Echo Server or Pusher.
- You get tighter integration with Laravel’s broadcasting system.
- It's easy to run and manage with Laravel Sail or your custom setup.
Why Use Reverb?
Here are some major reasons to consider using Reverb:
1. Zero External Dependencies
You no longer need services like Pusher or setup-intensive packages. Reverb is integrated directly into Laravel 11.
2. Better Performance and Control
Because it's local, you have more control over the configuration, security, and optimization.
3. Developer Experience
Integrated with Laravel Sail and artisan commands — easy to start, debug, and monitor.
Prerequisites
- Laravel 11
- Node.js & npm installed (for frontend setup)
- Laravel Breeze/Jetstream (optional, for quick UI scaffolding)
- Laravel Sail or a custom server
Step-by-Step Guide: Setting Up Reverb in Laravel 11
Step 1: Create a New Laravel 11 Project
laravel new realtime-app
cd realtime-app
Or, using Composer:
composer create-project laravel/laravel:^11.0 realtime-app
Step 2: Install Laravel Breeze (Optional)
This gives you authentication and frontend scaffolding quickly.
composer require laravel/breeze --dev
php artisan breeze:install
npm install && npm run dev
php artisan migrate
Step 3: Configure Broadcasting in .env
Set the default broadcaster to reverb:
BROADCAST_DRIVER=reverb
Step 4: Publish and Configure Reverb
php artisan reverb:publish
This creates the reverb.php config file. You can modify host, port, middleware, and more here.
Step 5: Create a Broadcast Event
Generate a new event:
php artisan make:event MessageSent
In app/Events/MessageSent.php, implement ShouldBroadcast:
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class MessageSent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $message;
public function __construct($message)
{
$this->message = $message;
}
public function broadcastOn()
{
return new PrivateChannel('chat');
}
}
Step 6: Broadcast Event
From your controller or anywhere:
broadcast(new MessageSent("Hello from Laravel Reverb!"));
Step 7: Frontend Listener with Laravel Echo
Install Echo and the Reverb connector:
npm install --save laravel-echo pusher-js
In your resources/js/bootstrap.js:
import Echo from 'laravel-echo';
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'reverb',
key: '',
wsHost: window.location.hostname,
wsPort: 6001,
forceTLS: false,
disableStats: true,
});
window.Echo.private('chat')
.listen('MessageSent', (e) => {
console.log('Message received:', e.message);
});
Step 8: Run Reverb Server
If you're using Laravel Sail:
./vendor/bin/sail up -d
./vendor/bin/sail artisan reverb:start
Or directly:
php artisan reverb:start
Make sure port 6001 is open.
Testing Real-Time Events
Trigger your broadcast (e.g., from a route/controller), then check your browser console for received events.
You’ve successfully set up real-time broadcasting in Laravel 11 using Reverb — no third-party WebSocket services needed!
Troubleshooting Tips
- CORS Issues? Ensure correct headers in your frontend and
reverb.php. - Private Channels? Authenticate users correctly using Laravel’s broadcast routes.
- Firewall/Port: Port 6001 must be open in your local or cloud environment.
Conclusion
Laravel 11’s Reverb simplifies real-time broadcasting, eliminating the complexity and cost of third-party services. With seamless Laravel integration, developer-friendly commands, and full control, Reverb is the future of real-time Laravel apps.
Start using Reverb today and bring your Laravel apps to life with real-time power.
