| Install | |
|---|---|
composer require rohitshakya/laravel-beacon |
|
| Latest Version: | 2.0.0 |
| PHP: | ^8.2 |
Like a lighthouse in the dark, Beacon signals new activity to your users.
Beacon is a drop-in notification UI for Laravel that provides a topbar dropdown, inbox page, and realtime updates using Livewire and broadcasting. It is designed to be elegant, customizable, and easy to integrate into any Laravel app.
A beacon is a guiding signal — a lighthouse that alerts ships of activity and direction.
This package acts the same way:
Instead of silently storing notifications in the database, Beacon announces them to users through UI, events, and realtime broadcasting.
composer require your-vendor/beacon
Publish config:
php artisan vendor:publish --tag=beacon-config
Publish views (optional):
php artisan vendor:publish --tag=beacon-views
<x-beacon::topbar />
Or if using Livewire driver:
@livewire('beacon.topbar')
$user->notify(new SomeNotification());
Beacon will automatically appear in UI.
window.addEventListener('beacon:notification', (e) => {
console.log('New notification', e.detail);
});
Beacon supports:
Make sure Echo is running.
Example:
window.Echo.private(`App.Models.User.${userId}`)
.notification((notification) => {
window.dispatchEvent(
new CustomEvent('beacon:notification', { detail: notification })
);
});
config/beacon.php
return [
'views' => [
'topbar' => 'beacon::topbar.default',
'inbox' => 'beacon::inbox.default',
'item' => 'beacon::item.default',
],
'topbar' => [
'driver' => 'livewire',
'limit' => 8,
'view' => 'beacon::topbar.default',
],
'realtime' => [
'enabled' => true,
'channel' => 'App.Models.User.{id}',
'browser_event' => 'beacon:notification',
],
'routes' => [
'enabled' => true,
'prefix' => '/beacon',
'middleware' => ['web', 'auth'],
],
];
Override UI templates.
'views' => [
'topbar' => 'beacon::topbar.default',
'inbox' => 'beacon::inbox.default',
'item' => 'beacon::item.default',
],
You can replace with your own:
'topbar' => 'resources/views/components/my-topbar.blade.php'
'topbar' => [
'driver' => 'livewire',
'limit' => 8,
]
| Option | Description |
|---|---|
| driver | livewire or blade |
| limit | notifications shown in dropdown |
'realtime' => [
'enabled' => true,
'channel' => 'App.Models.User.{id}',
'browser_event' => 'beacon:notification',
]
| Option | Description |
|---|---|
| enabled | Enable Echo listening |
| channel | Private channel pattern |
| browser_event | Event fired in browser |
'routes' => [
'enabled' => true,
'prefix' => '/beacon',
'middleware' => ['web', 'auth'],
]
Provides:
/beacon/inboxPublish views:
php artisan vendor:publish --tag=beacon-views
Then edit:
resources/views/vendor/beacon/
You can redesign everything.
Beacon dispatches:
beacon:notification
Example:
window.addEventListener('beacon:notification', e => {
toast(e.detail.title)
})
By default:
'middleware' => ['web', 'auth']
You may change to:
['web', 'auth:sanctum']
Create a test page:
$user->notify(new TestNotification());
Open two tabs → watch realtime.
PRs welcome.
git clone
composer install
npm install
MIT
Built with ❤️ for Laravel ecosystem.