Laravel Web Push Notifications

sandeepa dilakshana admin  | Laravel |  1 month ago
Laravel Web Push Notifications
sandeepa dilakshana admin  | Laravel |  1 month ago

Web push notifications let your app reach users even when they don't have a browser tab open — no native app required. The Laravel Notification Channel project is a community collection of notification drivers for Laravel, and their Web push notification channels adds push notifications into Laravel's existing notification system, so you write a notification class the same way you would for mail or Slack. Under the hood, it talks directly to the browser's Push API using VAPID keys, with no third-party push service in between. Chrome, Firefox, Edge, and Safari are all supported.


This adds VAPID_PUBLIC_KEY and VAPID_PRIVATE_KEY to your .env file. The public key gets shared with the browser when a user subscribes; the private key signs outgoing push messages so browsers can verify they came from you. Treat these like any other secret, and don't rotate them — every existing subscription is tied to the key pair that created it.

If you're targeting Safari or iOS, you'll also need to add a VAPID_SUBJECT — a URL or mailto: address that identifies your app. Apple requires it and will return a BadJwtToken error without it.

Tags


sandeepa dilakshana admin
Written By sandeepa dilakshana admin

Web Developer