Download the PHP package slfomin/pwa-laravel without Composer
On this page you can find all versions of the php package slfomin/pwa-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download slfomin/pwa-laravel
More information about slfomin/pwa-laravel
Files in slfomin/pwa-laravel
Package pwa-laravel
Short Description Comprehensive PWA integration for Laravel 13 + Vite 7 with Inertia v3 support
License MIT
Homepage https://github.com/slfomin/pwa-laravel
Informations about the package pwa-laravel
pwa-laravel
Full PWA integration for Laravel 13 + Vite 7 with optional Inertia.js v3 support.
- Static or dynamic Web App Manifest (per-locale, per-tenant via resolvers)
- Service Worker registration via Blade directives
- Automatic icon generation (standard, maskable, apple-touch, favicon) via
intervention/image - Inertia v3 adapter: shared PWA props, middleware for correct SW/Inertia caching
- JS companion package
@slfomin/pwa-laravelwrappingvite-plugin-pwa - PHPStan level 8, PHP 8.4+
Requirements
| Dependency | Version |
|---|---|
| PHP | ^8.4 |
| Laravel | ^13.0 |
| Vite | ^6.0 || ^7.0 |
| vite-plugin-pwa | ^1.0 |
| Inertia.js (optional) | ^3.0 |
Installation
Run the interactive installer:
This publishes config/pwa.php and prints the next steps.
Quick Start
1. Place your source icon
Put a square PNG (512×512 or larger) at resources/images/pwa-icon.png, then generate all sizes:
Icons are written to public/icons/ and cover standard, maskable, Apple Touch, and favicon sizes.
2. Add Blade directives to your layout
@pwaMeta renders the <link rel="manifest">, theme-color, apple-touch-icon, favicons, and other mobile meta tags.
@pwaRegisterSW injects a small inline script that registers the service worker on page load.
3. Install the JS companion
Via npm (recommended):
From the composer package (no npm required):
Pre-built files are shipped inside the composer package at vendor/slfomin/pwa-laravel/dist/.
Import directly in vite.config.js:
vite-plugin-pwais still a required peer dependency — install it withddev npm install -D vite-plugin-pwa.
4. Configure Vite
5. Build
That's it — your Laravel app is now a PWA.
Inertia.js v3 Integration
Vite config
Shared props
The package automatically calls Inertia::share('pwa', ...) if Inertia is installed and
pwa.inertia.auto_detect is true (default). Every page receives:
usePwa() — Vue 3
usePwa() — React 19
Middleware
Add pwa.inertia to your routes to set correct Vary and Cache-Control headers,
preventing the service worker from caching Inertia XHR responses:
Dynamic Manifest
Switch the driver to dynamic to serve a manifest generated by Laravel on each request:
Implement your resolver:
Bind it in AppServiceProvider:
PWA Shortcuts
Shortcuts are quick-action entries shown in the OS context menu (long-press / right-click on the app icon).
Declare them with #[PwaShortcut] on any controller method that is mapped to a route:
- The shortcut URL is auto-derived from the route URI.
- Icon sizes and type are auto-probed from
public/when omitted. - When
manifest.driver = dynamic, shortcuts are injected into the manifest automatically. - Use
manifest.data.shortcutsinconfig/pwa.phpto provide a static list instead.
See docs/shortcuts.md for the full reference.
Blade Directives
| Directive | Output |
|---|---|
@pwaMeta |
<link rel="manifest">, theme-color, apple-touch-icon, favicons, mobile meta |
@pwaRegisterSW |
Inline <script> registering the service worker |
@pwaInstallButton('Install') |
A hidden <button> that appears when the browser's install prompt fires |
Artisan Commands
| Command | Description |
|---|---|
pwa:install |
Interactive installer — publishes config and prints next steps |
pwa:generate-icons |
Generate full icon set from source PNG |
pwa:publish-manifest |
Write manifest.webmanifest from config (no Vite build required) |
pwa:shortcuts:list |
List all discovered PWA shortcuts (--no-cache to bypass cache) |
pwa:shortcuts:cache |
Discover shortcuts and cache the result for production |
pwa:shortcuts:clear |
Flush the shortcuts cache |
pwa:generate-icons
pwa:publish-manifest
Configuration Reference
All options live in config/pwa.php. Key .env variables:
| Variable | Default | Description |
|---|---|---|
PWA_MANIFEST_DRIVER |
static |
static (Vite file) or dynamic (Laravel controller) |
PWA_MANIFEST_ROUTE |
/manifest.webmanifest |
URL the browser fetches |
APP_NAME |
Laravel |
PWA full name |
PWA_SHORT_NAME |
APP_NAME |
Short name for the home screen icon |
PWA_DESCRIPTION |
`` | PWA description |
PWA_DISPLAY |
standalone |
Display mode (standalone, fullscreen, minimal-ui, browser) |
PWA_THEME_COLOR |
#000000 |
Theme / status-bar color |
PWA_BG_COLOR |
#ffffff |
Splash screen background color |
PWA_SW_STRATEGY |
generateSW |
generateSW or injectManifest |
PWA_SW_URL |
/sw.js |
Service worker registration URL |
PWA_SW_DEV |
false |
Enable service worker in local dev |
PWA_MANIFEST_CACHE |
true |
Cache dynamic manifest responses |
PWA_MANIFEST_CACHE_TTL |
3600 |
Cache TTL in seconds |
PWA_SHORTCUTS_CACHE |
null |
Cache discovered shortcuts (true/false; null = auto by APP_ENV) |
Facade & Contracts
Extension points in SlFomin\PwaLaravel\Contracts:
| Contract | Purpose |
|---|---|
ManifestDriver |
Custom manifest delivery strategy |
ManifestResolver |
Context-aware manifests (tenant, locale, user role) |
IconGenerator |
Replace intervention/image with another library |
ServiceWorkerStrategy |
Extend Vite plugin options |
Events
Hook into the PWA lifecycle with five Laravel events
(ManifestResolving, ManifestResolved, ServiceWorkerRequested, IconsGenerated,
ManifestPublished):
See docs/events.md for the full reference.
Testing
Changelog
Please see CHANGELOG for recent changes.
Contributing
Please see CONTRIBUTING for details.
Security
Please review our security policy to report vulnerabilities.
Credits
- Vyacheslav Brynzevich
- All Contributors
License
MIT. Please see License File for more information.
All versions of pwa-laravel with dependencies
spatie/laravel-package-tools Version ^1.93
illuminate/contracts Version ^13.0
illuminate/support Version ^13.0
illuminate/http Version ^13.0
illuminate/routing Version ^13.0
intervention/image Version ^3.10