A beautiful Laravel Livewire chat component built with Flux UI, supporting both standard polling and real-time messaging with Laravel Reverb.
- π¨ Beautiful UI - Built with Flux UI components
- β‘ Real-time Support - Optional Laravel Reverb integration
- π Fallback Polling - Works without WebSocket server
- π Multi-language - English and Norwegian included
- π± Responsive Design - Works on all devices
- π§ Highly Configurable - Customize everything
- π Easy Installation - One command setup
- PHP 8.3+
- Laravel 12.0+
- Livewire 3.0+
- Flux UI Pro 2.0+
Install via Composer:
composer require wirelabs/fluxchatRun the installation command:
php artisan fluxchat:installRun migrations:
php artisan migrateAdd the component to your Blade view:
<livewire:fluxchat :contacts="$contacts" />Where $contacts is a collection of users/contacts:
// In your controller
$contacts = User::where('id', '!=', auth()->id())->get();
return view('chat', compact('contacts'));Publish the config file:
php artisan vendor:publish --tag="fluxchat-config"// config/fluxchat.php
return [
'realtime' => [
'enabled' => env('FLUXCHAT_REALTIME_ENABLED', false),
'auto_refresh_interval' => env('FLUXCHAT_AUTO_REFRESH', 5), // seconds
],
'ui' => [
'theme' => env('FLUXCHAT_THEME', 'dark'),
'avatar_size' => env('FLUXCHAT_AVATAR_SIZE', 'sm'),
],
];Add to your .env file:
# Standard mode (polling every 5 seconds)
FLUXCHAT_REALTIME_ENABLED=false
FLUXCHAT_AUTO_REFRESH=5
# Real-time mode (requires Reverb)
FLUXCHAT_REALTIME_ENABLED=true
BROADCAST_CONNECTION=reverbFluxChat supports two modes:
- Polls for new messages every 5 seconds
- No additional server required
- Works everywhere
- Instant message delivery via WebSockets
- Requires Laravel Reverb
- Better user experience
To enable real-time messaging:
- Install and configure Laravel Reverb:
php artisan install:broadcasting- Update your
.env:
FLUXCHAT_REALTIME_ENABLED=true
BROADCAST_CONNECTION=reverb- Start the Reverb server:
php artisan reverb:start<livewire:fluxchat
:contacts="$contacts"
contact-model="App\Models\Contact"
contact-name-field="full_name"
:contact-search-fields="['name', 'email']"
/>Publish the views to customize:
php artisan vendor:publish --tag="fluxchat-views"Views will be published to resources/views/vendor/fluxchat/.
Publish language files:
php artisan vendor:publish --tag="fluxchat-lang"Add your own translations in resources/lang/vendor/fluxchat/.
// In your Livewire component
use Wirelabs\FluxChat\Models\Conversation;
use Wirelabs\FluxChat\Models\Message;
// Create a conversation
$conversation = Conversation::create([
'type' => 'private',
'is_group' => false,
]);
// Add participants
$conversation->addParticipant(auth()->user());
$conversation->addParticipant($contact);
// Send a message
$message = $conversation->messages()->create([
'sendable_id' => auth()->id(),
'sendable_type' => User::class,
'body' => 'Hello!',
'type' => 'text',
]);Listen to FluxChat events:
// EventServiceProvider
use Wirelabs\FluxChat\Events\MessageSent;
protected $listen = [
MessageSent::class => [
SendMessageNotification::class,
],
];composer test| Property | Type | Default | Description |
|---|---|---|---|
contacts |
Collection/Array | [] |
Available contacts |
contactModel |
String | User::class |
Contact model class |
contactNameField |
String | 'name' |
Contact name field |
contactSearchFields |
Array | ['name'] |
Searchable fields |
maxContacts |
Integer | 10 |
Max contacts to show |
messages()- Get all messagesparticipants()- Get all participantsaddParticipant($user)- Add participantmarkAsRead($user)- Mark as read
conversation()- Get conversationsendable()- Get senderisEdited()- Check if edited
- Check Reverb is running:
php artisan reverb:start --debug- Verify configuration:
php artisan config:show broadcasting.default- Check browser console for WebSocket connections
- Ensure auto-refresh is enabled:
FLUXCHAT_AUTO_REFRESH=5- Check Livewire is working:
@livewireScriptsContributions are welcome! Please see CONTRIBUTING.md for details.
The MIT License (MIT). Please see License File for more information.
- Built by Wirelabs
- Powered by Laravel
- UI by Flux UI
- Real-time by Laravel Reverb
Made with β€οΈ by Wirelabs