PHPackages                             slfomin/pwa-laravel - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. slfomin/pwa-laravel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

slfomin/pwa-laravel
===================

Comprehensive PWA integration for Laravel 13 + Vite 7 with Inertia v3 support

v0.2.0(2w ago)00[6 PRs](https://github.com/SlFomin/pwa-laravel/pulls)MITPHPPHP ^8.4CI passing

Since May 23Pushed 3d agoCompare

[ Source](https://github.com/SlFomin/pwa-laravel)[ Packagist](https://packagist.org/packages/slfomin/pwa-laravel)[ Docs](https://github.com/slfomin/pwa-laravel)[ GitHub Sponsors](https://github.com/SlFomin)[ RSS](/packages/slfomin-pwa-laravel/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (19)Versions (4)Used By (0)

pwa-laravel
===========

[](#pwa-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/22f17ebc3a1693f5cd946a9f557bf55ac1b630e0af7d21ca18462b17ce3a5cfc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736c666f6d696e2f7077612d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/slfomin/pwa-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/8e556bf8db6053b4127659d1cbf12bcaf564de664b7791bfd88e965d882c78c0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736c666f6d696e2f7077612d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/slfomin/pwa-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/b40fc889f88d8c1abf9b426f839026a5b028ceade923615cece55e2864928a09/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736c666f6d696e2f7077612d6c61726176656c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/slfomin/pwa-laravel/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![PHPStan](https://camo.githubusercontent.com/fff00cebb924e124a7335e6bd8ca8f8cf38869463c1654eff45d0939f1f21c57/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://phpstan.org)[![Total Downloads](https://camo.githubusercontent.com/03b2e20ef52958e3199a20e39e112a5ccafc59846c5e98e6c4bbf49f2c1aa73f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736c666f6d696e2f7077612d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/slfomin/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-laravel` wrapping `vite-plugin-pwa`
- PHPStan level 8, PHP 8.4+

Requirements
------------

[](#requirements)

DependencyVersionPHP^8.4Laravel^13.0Vite^6.0 || ^7.0vite-plugin-pwa^1.0Inertia.js (optional)^3.0Installation
------------

[](#installation)

```
ddev composer require slfomin/pwa-laravel
```

Run the interactive installer:

```
ddev artisan pwa:install
```

This publishes `config/pwa.php` and prints the next steps.

Quick Start
-----------

[](#quick-start)

### 1. Place your source icon

[](#1-place-your-source-icon)

Put a square PNG (512×512 or larger) at `resources/images/pwa-icon.png`, then generate all sizes:

```
ddev artisan pwa:generate-icons
```

Icons are written to `public/icons/` and cover standard, maskable, Apple Touch, and favicon sizes.

### 2. Add Blade directives to your layout

[](#2-add-blade-directives-to-your-layout)

```

    @pwaMeta
    @vite(['resources/css/app.css', 'resources/js/app.js'])

    {{ $slot }}
    @pwaRegisterSW

```

`@pwaMeta` renders the ``, 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

[](#3-install-the-js-companion)

**Via npm (recommended):**

```
ddev npm install -D vite-plugin-pwa @slfomin/pwa-laravel
```

**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`:

```
import { laravelPwa } from '../../vendor/slfomin/pwa-laravel/dist/index.js';
// framework composables (optional):
// import { usePwa } from '../../vendor/slfomin/pwa-laravel/dist/vue.js';
```

> `vite-plugin-pwa` is still a required peer dependency — install it with `ddev npm install -D vite-plugin-pwa`.

### 4. Configure Vite

[](#4-configure-vite)

```
// vite.config.js
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import { laravelPwa } from '@slfomin/pwa-laravel';

export default defineConfig({
    plugins: [
        laravel({
            input: ['resources/css/app.css', 'resources/js/app.js'],
            refresh: true,
        }),
        laravelPwa({
            strategies: 'generateSW',
            manifest: false, // manifest is served by Laravel, not Vite
            workbox: {
                globPatterns: ['**/*.{js,css,html,ico,png,svg,webp,woff,woff2}'],
            },
        }),
    ],
});
```

### 5. Build

[](#5-build)

```
ddev npm run build
```

That's it — your Laravel app is now a PWA.

---

Inertia.js v3 Integration
-------------------------

[](#inertiajs-v3-integration)

### Vite config

[](#vite-config)

```
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import inertia from '@inertiajs/vite';
import { laravelPwa } from '@slfomin/pwa-laravel';

export default defineConfig({
    plugins: [
        laravel({ input: ['resources/css/app.css', 'resources/js/app.js'], refresh: true }),
        inertia(),
        laravelPwa({
            inertia: true,          // sets navigateFallback: '/' and excludes API routes
            strategies: 'generateSW',
            manifest: false,
            devOptions: { enabled: false }, // must be off when inertia() plugin is active
        }),
    ],
});
```

### Shared props

[](#shared-props)

The package automatically calls `Inertia::share('pwa', ...)` if Inertia is installed and `pwa.inertia.auto_detect` is `true` (default). Every page receives:

```
{
    pwa: {
        manifest_url: string,
        sw: { url, scope, register_type, auto_register, available },
        navigate_fallback: string | null,
        is_ssr: boolean,
    }
}
```

### `usePwa()` — Vue 3

[](#usepwa--vue-3)

```
import { usePwa } from '@slfomin/pwa-laravel/vue';

const { manifestUrl, swInfo, navigateFallback, isOffline } = usePwa();
```

### `usePwa()` — React 19

[](#usepwa--react-19)

```
import { usePwa } from '@slfomin/pwa-laravel/react';

const { manifestUrl, swInfo, navigateFallback, isOffline } = usePwa();
```

### Middleware

[](#middleware)

Add `pwa.inertia` to your routes to set correct `Vary` and `Cache-Control` headers, preventing the service worker from caching Inertia XHR responses:

```
// routes/web.php
Route::middleware(['web', 'pwa.inertia'])->group(function () {
    // your Inertia routes
});
```

---

Dynamic Manifest
----------------

[](#dynamic-manifest)

Switch the driver to `dynamic` to serve a manifest generated by Laravel on each request:

```
// config/pwa.php
'manifest' => [
    'driver' => 'dynamic',
    'dynamic' => [
        'resolver' => \App\Pwa\TenantManifestResolver::class,
        'cache' => true,
        'cache_ttl' => 3600,
    ],
],
```

Implement your resolver:

```
namespace App\Pwa;

use Illuminate\Http\Request;
use SlFomin\PwaLaravel\Contracts\ManifestResolver;
use SlFomin\PwaLaravel\Manifest\ManifestBuilder;

final class TenantManifestResolver implements ManifestResolver
{
    public function resolve(Request $request, ManifestBuilder $default): ManifestBuilder
    {
        $tenant = $request->user()?->tenant;

        return $tenant
            ? $default->name($tenant->name)->themeColor($tenant->brand_color)
            : $default;
    }

    public function cacheKey(Request $request): ?string
    {
        return 'tenant.'.($request->user()?->tenant_id ?? 'guest');
    }
}
```

Bind it in `AppServiceProvider`:

```
$this->app->bind(
    \SlFomin\PwaLaravel\Contracts\ManifestResolver::class,
    \App\Pwa\TenantManifestResolver::class,
);
```

---

PWA Shortcuts
-------------

[](#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:

```
use SlFomin\PwaLaravel\Attributes\PwaShortcut;
use SlFomin\PwaLaravel\Core\Shortcuts\ShortcutIcon;

class AuthController
{
    #[PwaShortcut(name: 'Login', icon: '/icons/login.png')]
    public function showLogin() {}

    #[PwaShortcut(
        name: 'Register',
        icons: [
            new ShortcutIcon('/icons/register-96.png', '96x96'),
            new ShortcutIcon('/icons/register-192.png', '192x192'),
        ],
    )]
    public function showRegister() {}
}
```

- 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.shortcuts` in `config/pwa.php` to provide a static list instead.

```
ddev artisan pwa:shortcuts:list   # inspect discovered shortcuts
ddev artisan pwa:shortcuts:cache  # pre-warm cache (run after route:cache in deploy)
ddev artisan pwa:shortcuts:clear  # flush cache
```

See [docs/shortcuts.md](docs/shortcuts.md) for the full reference.

---

Blade Directives
----------------

[](#blade-directives)

DirectiveOutput`@pwaMeta```, theme-color, apple-touch-icon, favicons, mobile meta`@pwaRegisterSW`Inline `` registering the service worker`@pwaInstallButton('Install')`A hidden `` that appears when the browser's install prompt fires---

Artisan Commands
----------------

[](#artisan-commands)

CommandDescription`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`

[](#pwagenerate-icons)

```
pwa:generate-icons [source] [--output=] [--dry-run]

  source     Path to source PNG (≥512×512, square). Default: pwa.icons.source from config.
  --output   Output directory. Default: pwa.icons.output_path from config.
  --dry-run  Validate source without writing any files.

```

### `pwa:publish-manifest`

[](#pwapublish-manifest)

```
pwa:publish-manifest [--path=] [--pretty]

  --path    Output file path. Default: pwa.manifest.static_path from config.
  --pretty  Pretty-print the JSON output.

```

---

Configuration Reference
-----------------------

[](#configuration-reference)

All options live in `config/pwa.php`. Key `.env` variables:

VariableDefaultDescription`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 &amp; Contracts
----------------------

[](#facade--contracts)

```
use SlFomin\PwaLaravel\Facades\Pwa;

Pwa::manifest();         // ManifestBuilder for the current request
Pwa::manifestUrl();      // string — URL of the manifest
Pwa::serviceWorkerUrl(); // string — URL of the service worker
Pwa::worker();           // WorkerManager instance
Pwa::driver();           // ManifestDriver instance
```

Extension points in `SlFomin\PwaLaravel\Contracts`:

ContractPurpose`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

[](#events)

Hook into the PWA lifecycle with five Laravel events (`ManifestResolving`, `ManifestResolved`, `ServiceWorkerRequested`, `IconsGenerated`, `ManifestPublished`):

```
use SlFomin\PwaLaravel\Events\PwaEvents;
use SlFomin\PwaLaravel\Events\ManifestResolved;

PwaEvents::manifestResolved(function (ManifestResolved $event): void {
    // last-chance mutation before the JSON is serialized
    $event->manifest->name('My App — '.app()->getLocale());
});
```

See [docs/events.md](docs/events.md) for the full reference.

---

Testing
-------

[](#testing)

```
ddev composer test      # Pest (119 tests)
ddev composer analyse   # PHPStan level 8
ddev composer format    # Laravel Pint
ddev composer ci        # all three in sequence
```

---

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for recent changes.

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

[](#contributing)

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

Security
--------

[](#security)

Please review [our security policy](../../security/policy) to report vulnerabilities.

Credits
-------

[](#credits)

- [Vyacheslav Brynzevich](https://github.com/SlFomin)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance98

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85% 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 ~1 days

Total

3

Last Release

15d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4e315ea0f97d20e44c61d51135062328b63218d36b22f9ca2ec864ac7206ddfe?d=identicon)[SlFomin](/maintainers/SlFomin)

---

Top Contributors

[![SlFomin](https://avatars.githubusercontent.com/u/7039655?v=4)](https://github.com/SlFomin "SlFomin (96 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")

---

Tags

laravelinertiavitepwamanifestservice worker

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/slfomin-pwa-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/slfomin-pwa-laravel/health.svg)](https://phpackages.com/packages/slfomin-pwa-laravel)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

76318.2M110](/packages/laravel-mcp)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)[api-platform/laravel

API Platform support for Laravel

59156.3k10](/packages/api-platform-laravel)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1232.2k16](/packages/fleetbase-core-api)[ralphjsmit/laravel-glide

Auto-magically generate responsive images from static image files.

4923.6k5](/packages/ralphjsmit-laravel-glide)

PHPackages © 2026

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