Why Laravel Reverb for WebSockets?
Laravel Reverb is a first-party, high-performance WebSocket server built by the Laravel team. Key advantages:
- No Node.js — pure PHP (powered by ReactPHP)
- Pusher-compatible API → works seamlessly with Laravel Echo
- Scalable with Redis for horizontal scaling
- Official support & active maintenance (unlike abandoned third-party packages)
- Built-in dashboard for monitoring connections & events
- Free & self-hosted (or managed via Laravel Cloud)
Reverb is now the standard for Laravel 11+ / 12 real-time apps in 2026.
The popular beyondcode/laravel-websockets package is no longer maintained (abandoned since ~2024). The maintainers officially recommend migrating to Laravel Reverb.
Use Reverb for all new projects. The legacy section below is only for maintaining older apps.

Table Of Content
1 Prerequisites
- PHP ≥ 8.2
- Laravel 12 fresh install
- Composer
- Node.js & npm (only for frontend assets + Laravel Echo)
- Redis (strongly recommended for production scaling)
- Database (MySQL / PostgreSQL / SQLite)
2 Introduction
In this step-by-step tutorial, you'll learn:
- Why choose Reverb over third-party packages
- Full installation & configuration
- Building a real-time chat example
- Production deployment tips
3 Create a Fresh Laravel 12 Project
3.1 Install Laravel Project
composer create-project laravel/laravel:^12.0 laravel12-webSockets
Navigate to your project directory:
cd laravel12-webSockets
3.2 Database Configuration in .env
cp .env.example .env
Open .env and configure the database section based on your setup. Here are the most common examples:
MySQL / MariaDB (Most Common)
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_db # Create this database first in MySQL
DB_USERNAME=root # or your username
DB_PASSWORD= # leave blank if no password, or your password
PostgreSQL
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=laravel_db
DB_USERNAME=postgres
DB_PASSWORD=your_password
SQLite (Great for Quick Testing / Small Apps – No Server Needed)
DB_CONNECTION=sqlite
# Comment out or remove the other DB_* lines
# Then create an empty file:
touch database/database.sqlite
4 Modern & Recommended – Install Laravel Reverb
Install Broadcasting with Reverb
Run this single command (it handles everything):
php artisan install:broadcasting --reverb
This:
- Installs Reverb
- Publishes config files (config/reverb.php, .env keys)
- Sets up Laravel Echo frontend scaffolding
Review .envChanges
New keys added automatically:
BROADCAST_DRIVER=reverb
REVERB_APP_ID=your-app-id
REVERB_APP_KEY=your-key
REVERB_APP_SECRET=your-secret
REVERB_HOST=localhost
REVERB_PORT=8080
REVERB_SCHEME=http
VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"
For production: change REVERB_HOST to your domain, use https/wss, and enable Redis.
Start Reverb Server (Development)
php artisan reverb:start --debug
Keep this running in a separate terminal.
Compile Frontend Assets
npm install
npm run dev
5 Create Broadcast Event
php artisan make:event MessageSent --broadcast
Edit app/Events/MessageSent.php:
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class MessageSent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $username;
public $message;
public function __construct(string $username, string $message)
{
$this->username = $username;
$this->message = $message;
}
public function broadcastOn(): array
{
return [new Channel('chat')];
}
public function broadcastAs(): string
{
return 'message.sent'; // Optional custom name
}
}
6 Create Controller to Trigger Event
php artisan make:controller ChatController
Edit app/Http/Controllers/ChatController.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Events\MessageSent;
class ChatController extends Controller
{
public function send(Request $request)
{
$request->validate([
'username' => 'required|string|max:50',
'message' => 'required|string|max:500',
]);
broadcast(new MessageSent(
$request->username,
$request->message
))->toOthers();
return response()->json(['status' => 'Message broadcasted!']);
}
}
7 Chat UI Example
<!DOCTYPE html>
<html>
<head>
<title>Laravel 12 Real-Time Chat – Reverb</title>
@vite(['resources/js/app.js'])
</head>
<body>
<h1>Real-Time Chat (Laravel Reverb)</h1>
<input id="username" placeholder="Your name" />
<input id="message" placeholder="Type a message..." />
<button onclick="sendMessage()">Send</button>
<ul id="messages"></ul>
<script>
Echo.channel('chat')
.listen('.message.sent', (e) => {
const li = document.createElement('li');
li.textContent = `${e.username}: ${e.message}`;
document.getElementById('messages').appendChild(li);
});
function sendMessage() {
const username = document.getElementById('username').value;
const message = document.getElementById('message').value;
if (!username || !message) return;
fetch('/chat/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
},
body: JSON.stringify({ username, message })
}).then(() => {
document.getElementById('message').value = '';
});
}
</script>
</body>
</html>
8 Define Routes (routes/web.php or routes/api.php)
use App\Http\Controllers\ChatController;
Route::get('/chat', fn() => view('chat'))->name('chat');
Route::post('/chat/send', [ChatController::class, 'send']);
9 Test It
- Run Laravel: php artisan serve
- Run Reverb: php artisan reverb:start
- Open http://127.0.0.1:8000/chat in two tabs → send messages → watch real-time updates!
Open two browser tabs → send messages → see real-time chat without Node.js
10 Conclusion
You've now built a modern real-time chat app in Laravel 12 using Laravel Reverb — no Node.js needed.
Extend this for notifications, live presence, auctions, multiplayer games, and more.
Start building today: check the official Laravel Reverb docs for advanced features.
Written by Revathi M
PHP Developer & Technical Writer · 10+ years building web applications with CodeIgniter and Laravel
Revathi specializes in PHP backend development, authentication systems, and REST API design. She writes practical, production-tested tutorials at Get Sample Code to help developers build secure applications faster.
Frequently Asked Questions
Yes — Laravel Reverb is the official, first-party WebSocket server for Laravel 11+ / 12. It's pure PHP, Pusher-compatible, scalable with Redis, and actively maintained by the Laravel team. It eliminates the need for Node.js entirely and is now the recommended choice over third-party packages.
Laravel Reverb is official, uses ReactPHP (high-performance), supports Redis scaling out-of-the-box, and includes a built-in dashboard. The beyondcode/laravel-websockets package is abandoned (unmaintained since 2024) and no longer recommended. Reverb offers better performance, easier setup, and long-term support.
Technically yes for legacy projects, but it's strongly discouraged for new or active apps. The maintainers recommend migrating to Reverb. Reverb is faster, more secure, and integrated directly into Laravel's ecosystem.
Run one command: php artisan install:broadcasting --reverb. This installs Reverb, publishes configs, adds .env keys, and sets up Laravel Echo. Then start it with php artisan reverb:start for development.
Redis is optional for small apps but highly recommended for production (enables horizontal scaling and better performance). The queue is used for broadcasting events asynchronously — enable it in config/broadcasting.php for best results.
Install Laravel Echo and Pusher JS via npm, then initialize Echo with the local WebSocket host and port (default 6001).
Use Supervisor, Laravel Forge, or systemd to run php artisan reverb:start --host=0.0.0.0 --port=8080 as a daemon. Enable HTTPS/wss, restrict origins in config/reverb.php, and use Redis for scaling across multiple servers.
Yes — 100% compatible. Echo auto-configures with Reverb (Vite handles the keys). It works seamlessly with Vue, React, Livewire, Inertia, or plain JavaScript for real-time chat, notifications, presence, etc.
