PHPackages                             laravel-notification-channels/webpush - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. laravel-notification-channels/webpush

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

laravel-notification-channels/webpush
=====================================

Web Push Notifications driver for Laravel.

10.5.0(2mo ago)7984.5M↑10.4%12115MITPHPPHP ^8.2CI passing

Since Aug 12Pushed 2mo ago22 watchersCompare

[ Source](https://github.com/laravel-notification-channels/webpush)[ Packagist](https://packagist.org/packages/laravel-notification-channels/webpush)[ Docs](https://github.com/laravel-notification-channels/webpush)[ RSS](/packages/laravel-notification-channels-webpush/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (18)Versions (27)Used By (15)

Web Push Notifications Channel for Laravel
==========================================

[](#web-push-notifications-channel-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b3a35281da3cf73522d6fdbbe1141dcbe7e5abe132b11d47cc405fd639dcf68e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f776562707573682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/webpush)[![Build Status](https://github.com/laravel-notification-channels/webpush/workflows/tests/badge.svg)](https://github.com/laravel-notification-channels/webpush/workflows/tests/badge.svg)[![Quality Score](https://camo.githubusercontent.com/394768e17dc714dea812f3fd93c62c902f17cc800a7e2fc2d259ccbf65d5e9d0/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f776562707573682e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/laravel-notification-channels/webpush)[![Code Coverage](https://camo.githubusercontent.com/26205e82560b125c792a21f85b8ba2020f7bdd9a5612270a6ed0b7b3878eec8d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f776562707573682f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/laravel-notification-channels/webpush/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/39795b96340b440eff9be2eb47b91aef67c23c529845e53ee95aa0d521f577f7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f776562707573682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/webpush)

This package makes it easy to send web push notifications with Laravel.

Features
--------

[](#features)

- **Easy integration with Laravel notifications:** Seamlessly integrates with Laravel's notification system, allowing you to send web push notifications using familiar notification channels.
- **Multiple browser support:** Works with all major browsers that implement the [Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API), including Chrome, Firefox, Edge, and Safari.
- **VAPID support:** Easily generate and manage VAPID keys for secure browser authentication.
- **Flexible message options:** Customize notifications with title, body, icon, actions, TTL, and more. Supports advanced options like vibration, badge, image, and custom data payloads.
- **Subscription management:** Convenient methods to save, update, and delete push subscriptions directly on your notifiable models.
- **Automatic expired subscription cleanup:** When sending a push message to an expired subscription, the package detects expired endpoints (using the `expired` flag of `Minishlink\WebPush\MessageSentReport`). This package will automatically delete expired subscriptions.
- **Configurable and extendable:** Publish and customize the package's config file to fit your application's needs.

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require laravel-notification-channels/webpush
```

First, add the `NotificationChannels\WebPush\HasPushSubscriptions` trait to your `User` model:

```
use NotificationChannels\WebPush\HasPushSubscriptions;

class User extends Model
{
    use HasPushSubscriptions;
}
```

Next, publish the migration with:

```
php artisan vendor:publish --provider="NotificationChannels\WebPush\WebPushServiceProvider" --tag="migrations"
```

Run the migrate command to create the necessary table:

```
php artisan migrate
```

You can also publish the config file with:

```
php artisan vendor:publish --provider="NotificationChannels\WebPush\WebPushServiceProvider" --tag="config"
```

Generate the VAPID keys (required for browser authentication) with:

```
php artisan webpush:vapid
```

This command will set `VAPID_PUBLIC_KEY` and `VAPID_PRIVATE_KEY` in your `.env` file. You need the `VAPID_PUBLIC_KEY` as `applicationServerKey` when using the [Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API).

> **Note for Safari:**
>
> - If targeting Safari or iOS (especially after 2023), you **must** include the `VAPID_SUBJECT` variable in your `.env` file. This should be a valid URL (e.g. `https://example.com`) or a `mailto:` address (e.g. `mailto:admin@example.com`).
> - Apple will reject requests with a `BadJwtToken` error if `VAPID_SUBJECT` is missing or invalid.
> - The domain in `VAPID_SUBJECT` must be a valid, existing top-level domain (TLD).

**These keys must be safely stored and should not change.**

Usage
-----

[](#usage)

Now you can use the channel in your `via()` method inside the notification and send a generic web push notification:

```
use Illuminate\Notifications\Notification;
use NotificationChannels\WebPush\WebPushMessage;
use NotificationChannels\WebPush\WebPushChannel;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [WebPushChannel::class];
    }

    public function toWebPush($notifiable, $notification)
    {
        return (new WebPushMessage)
            ->title('Approved!')
            ->icon('/approved-icon.png')
            ->body('Your account was approved!')
            ->action('View account', 'view_account')
            ->options(['TTL' => 1000]);
            // ->data(['id' => $notification->id])
            // ->badge()
            // ->dir()
            // ->image()
            // ->lang()
            // ->renotify()
            // ->requireInteraction()
            // ->tag()
            // ->vibrate()
    }
}
```

### Declarative Web Push messages

[](#declarative-web-push-messages)

> **Note:** The specification for Declarative Web Push messages is still evolving and may change in the future. Browser support for this functionality is currently limited and may vary across platforms.

This package also supports [Declarative Web Push messages](https://www.w3.org/TR/push-api/#declarative-push-message), which aim to reduce the complexity of using push on the web in general and address some challenges of generic web push notifications like privacy concerns &amp; battery life on mobile by making a client-side service worker optional while remaining fully backwards compatible:

```
use Illuminate\Notifications\Notification;
use NotificationChannels\WebPush\DeclarativeWebPushMessage;
use NotificationChannels\WebPush\WebPushChannel;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [WebPushChannel::class];
    }

    public function toWebPush($notifiable, $notification)
    {
        return (new DeclarativeWebPushMessage)
            ->title('Approved!')
            ->icon('/approved-icon.png')
            ->body('Your account was approved!')
            ->action('View account', 'view_account', 'https://myapp.com/accounts')
            ->navigate('https://myapp.com');
            // ->data(['id' => $notification->id])
            // ->badge()
            // ->dir()
            // ->image()
            // ->lang()
            // ->mutable()
            // ->renotify()
            // ->requireInteraction()
            // ->silent()
            // ->tag()
            // ->timestamp()
            // ->vibrate()
            // ->options(['TTL' => 1000, 'contentType' => 'application/json'])
    }
}
```

You can find the available options [here](https://github.com/web-push-libs/web-push-php#notifications-and-default-options).

### Save/Update Subscriptions

[](#saveupdate-subscriptions)

To save or update a subscription, use the `updatePushSubscription($endpoint, $key = null, $token = null, $contentEncoding = null)` method on your user:

```
$user = \App\User::find(1);

$user->updatePushSubscription($endpoint, $key, $token, $contentEncoding);
```

The `$key` and `$token` are optional and are used to encrypt your notifications. However, all major browsers require encryption when sending notifications.

When using the [Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API), `$key` is the value of the `getKey('p256dh')` method, and `$token` is the value of the `getKey('auth')` method of the `PushSubscription` interface.

### Delete Subscriptions

[](#delete-subscriptions)

To delete a subscription, use the `deletePushSubscription($endpoint)` method on your user:

```
$user = \App\User::find(1);

$user->deletePushSubscription($endpoint);
```

Browser Compatibility
---------------------

[](#browser-compatibility)

See the [Push API](https://caniuse.com/#feat=push-api) browser compatibility.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information about what has changed recently.

Testing
-------

[](#testing)

```
composer test
```

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Cretu Eusebiu](https://github.com/cretueusebiu)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

74

—

ExcellentBetter than 100% of packages

Maintenance84

Actively maintained with recent releases

Popularity68

Solid adoption and visibility

Community42

Growing community involvement

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 53.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~139 days

Recently: every ~90 days

Total

26

Last Release

83d ago

Major Versions

5.1.1 → 6.0.02022-01-26

6.0.0 → 7.0.02022-03-29

7.1.0 → 8.0.02024-03-16

8.0.0 → 9.0.02024-07-10

9.0.0 → 10.0.02025-02-26

PHP version history (8 changes)0.0.1PHP &gt;=5.6.4

2.0.0PHP ^7.0

4.0.0PHP ^7.1

5.0.2PHP ^7.2

5.1.0PHP ^7.2|^8.0

6.0.0PHP ^8.0

8.0.0PHP ^8.1

10.0.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20937037?v=4)[Laravel Notification Channels](/maintainers/laravel-notification-channels)[@laravel-notification-channels](https://github.com/laravel-notification-channels)

---

Top Contributors

[![cretueusebiu](https://avatars.githubusercontent.com/u/1517945?v=4)](https://github.com/cretueusebiu "cretueusebiu (103 commits)")[![joostdebruijn](https://avatars.githubusercontent.com/u/1844089?v=4)](https://github.com/joostdebruijn "joostdebruijn (37 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (14 commits)")[![alberto-bottarini](https://avatars.githubusercontent.com/u/1442934?v=4)](https://github.com/alberto-bottarini "alberto-bottarini (5 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![web-flow](https://avatars.githubusercontent.com/u/19864447?v=4)](https://github.com/web-flow "web-flow (2 commits)")[![themsaid](https://avatars.githubusercontent.com/u/4332182?v=4)](https://github.com/themsaid "themsaid (2 commits)")[![themustafaomar](https://avatars.githubusercontent.com/u/46113191?v=4)](https://github.com/themustafaomar "themustafaomar (2 commits)")[![vesper8](https://avatars.githubusercontent.com/u/816028?v=4)](https://github.com/vesper8 "vesper8 (2 commits)")[![JayBizzle](https://avatars.githubusercontent.com/u/340752?v=4)](https://github.com/JayBizzle "JayBizzle (1 commits)")[![goaround](https://avatars.githubusercontent.com/u/5927337?v=4)](https://github.com/goaround "goaround (1 commits)")[![daronspence](https://avatars.githubusercontent.com/u/4062087?v=4)](https://github.com/daronspence "daronspence (1 commits)")[![martijnb92](https://avatars.githubusercontent.com/u/708544?v=4)](https://github.com/martijnb92 "martijnb92 (1 commits)")[![michaelLovesCoke](https://avatars.githubusercontent.com/u/55154214?v=4)](https://github.com/michaelLovesCoke "michaelLovesCoke (1 commits)")[![mpociot](https://avatars.githubusercontent.com/u/804684?v=4)](https://github.com/mpociot "mpociot (1 commits)")[![nmfzone](https://avatars.githubusercontent.com/u/10361906?v=4)](https://github.com/nmfzone "nmfzone (1 commits)")[![nonovd](https://avatars.githubusercontent.com/u/12936673?v=4)](https://github.com/nonovd "nonovd (1 commits)")[![oele-dev](https://avatars.githubusercontent.com/u/1950715?v=4)](https://github.com/oele-dev "oele-dev (1 commits)")[![oyed](https://avatars.githubusercontent.com/u/172114265?v=4)](https://github.com/oyed "oyed (1 commits)")[![patrickpietens](https://avatars.githubusercontent.com/u/132625?v=4)](https://github.com/patrickpietens "patrickpietens (1 commits)")

---

Tags

laravelnotificationswebpush

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/laravel-notification-channels-webpush/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-notification-channels-webpush/health.svg)](https://phpackages.com/packages/laravel-notification-channels-webpush)
```

###  Alternatives

[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

1.1k3.4M35](/packages/laravel-notification-channels-telegram)[laravel-notification-channels/fcm

FCM (Firebase Cloud Messaging) Notifications Driver for Laravel

5917.0M16](/packages/laravel-notification-channels-fcm)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[laravel-notification-channels/apn

Apple APN Push Notification Channel

2021.9M4](/packages/laravel-notification-channels-apn)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
