Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Service Workers Pwa Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-service-workers-pwa-knowledge-patch-nevaberry-plugins)
---
name: service-workers-pwa-knowledge-patch
description: Service Workers and Progressive Web Apps
version: null
license: MIT
metadata:
author: Nevaberry
---
# Service Workers and Progressive Web Apps
> [!CAUTION]
> Prerelease guidance may change before stable release. Each affected item
> carries its exact draft identifier beside the guidance.
Load this skill when working on service worker registration, fetch handling,
static routing, navigation clients, Workbox deployment, PWA installation
detection, or manifest identity, localization, appearance, and launch behavior.
## Reference index
| Reference | Topics |
| --- | --- |
| [Installed Application Detection](references/installation-detection.md) | Query limits; Android and Windows verification; in-scope and out-of-scope PWA detection |
| [Manifest and Launch Behavior](references/manifest-and-launch.md) | Installation; identity; localization; colors and icons; shortcuts; link capture; app windows |
| [Service Worker Static Routing](references/static-routing.md) | Feature detection; rule inputs and validation; cache sources; GET races; ordering; install failures |
| [Workbox Lifecycle and Deployment](references/workbox-lifecycle.md) | Registration and activation; fetch lifetime; preload; clients and messages; cache resets; Workbox builds, updates, and caching |
## Compatibility changes and failure conditions
### Module service workers reject top-level await
> **Prerelease (`service-workers-spec`):** This guidance may change before stable release.
A module worker's registration or update rejects with `TypeError` if its entry
module or a statically imported dependency uses top-level `await`. Move async
initialization into the events that need it and pass its promise to
`waitUntil()` or `respondWith()` as appropriate.
### Registration timing and Trusted Types
> **Prerelease (`service-workers-spec`):** This guidance may change before stable release.
For a document calling `navigator.serviceWorker.register()` or
`registration.update()`, the draft schedules the job after that document's
`DOMContentLoaded` event has been dispatched. An early call can remain pending
while parsing.
> **Prerelease (`service-workers-spec`):** This guidance may change before stable release.
When the page enforces Trusted Types for script sinks, pass a
`TrustedScriptURL` from an allowed policy as the registration's first argument.
### Activation can finish after a rejected lifetime promise
> **Prerelease (`service-workers-spec`):** This guidance may change before stable release.
During `activate`, the worker waits for `waitUntil()` promises to settle and can
reach `activated` even if one rejects. It must handle subsequent events if an
activation-time migration or cleanup fails or is interrupted.
### Response handling must not wait on itself
> **Prerelease (`20260804`):** This guidance may change before stable release.
`event.handled` fulfills once the worker hands over a response or lets the
request fall through, before response streaming completes. It rejects with a
`NetworkError` DOM exception if handling fails. Use it for follow-up work in
`waitUntil()`; awaiting it inside the promise passed to `respondWith()` creates
a dependency cycle.
### A pending navigation client can need the response first
> **Prerelease (`service-workers-spec`):** This guidance may change before stable release.
`clients.get(event.resultingClientId)` can wait until the new document is ready
to run or resolve to `undefined` if the reserved client is discarded. Keep the
lookup out of the promise passed to `respondWith()`, since the new document can
need the response before becoming ready.
### Navigation control and cache handles
> **Prerelease (`service-workers-spec`):** This guidance may change before stable release.
`WindowClient.navigate()` rejects with `TypeError` when the caller does not
control the client, including uncontrolled windows from
`clients.matchAll({ includeUncontrolled: true })`. Relative destinations resolve
against the worker's API base URL; pass an absolute URL when deriving it from
the page's location.
> **Prerelease (`service-workers-spec`):** This guidance may change before stable release.
After `await caches.delete(name)`, existing `Cache` references still work.
`caches.open(name)` opens a fresh cache if the name has not already been
recreated. Reopen by name after a reset before writing entries that should be
visible under that name.
## Static routing
### Detect support and pass rule objects
`InstallEvent.addRoutes()` has limited browser support. Check for the method in
the install listener and use the worker's `fetch` listener for required handling
where static routing is unavailable. Pass one rule object or a single array of
rules. `urlPattern` also accepts a `URLPattern` constructor input object or an
existing instance with `hasRegExpGroups === false`.
### Conditions, ordering, and registration failures
> **Prerelease (`service-workers-crd-2026-06`):** This guidance may change before stable release.
`urlPattern`, `requestMethod`, `requestMode`, `requestDestination`, and
`runningStatus` combine with AND. `runningStatus` accepts `"running"` or
`"not-running"`. Use `or` (an array) or `not` (one condition) as the sole
recognized member at its level; every condition needs a recognized member.
> **Prerelease (`service-workers-crd-2026-06`):** This guidance may change before stable release.
Calls to `addRoutes()` append rules; the first matching rule supplies the source.
The draft rejects registration with `TypeError` at the 1,024th condition object
across all rules or past 10 nesting levels, counting root and nested objects.
> **Prerelease (`service-workers-crd-2026-06`):** This guidance may change before stable release.
Router validation failures also reject with `TypeError`. Automatic install
lifetime extension fulfills even when registration rejects; use
`event.waitUntil(event.addRoutes(rule))` if that failure should fail installation.
### Cache fallback and GET races
> **Prerelease (`service-workers-crd-2026-06`):** This guidance may change before stable release.
`source: { cacheName: "images-v1" }` queries that cache with default matching
options; `"cache"` checks the first cache in storage order. A missing cache or
cache miss sends the request to the network, bypassing the fetch handler and
later routes.
> **Prerelease (`service-workers-crd-2026-06`):** This guidance may change before stable release.
Register a `fetch` listener during initial script evaluation before using
`"fetch-event"` or `"race-network-and-fetch-handler"`; otherwise `addRoutes()`
rejects with `TypeError`. Set `requestMethod: "GET"` for races: only GET races,
only a 2xx network response can win outright on the network branch, and
`event.preloadResponse` resolves to `undefined` on that route.
### Reuse an in-flight network response in a race
> **Prerelease (`20260804`):** This guidance may change before stable release.
Forward the original request with `fetch(event.request)` to let the browser
reuse the in-flight response. If the handler leaves the request unhandled, the
browser can use the already-started response, including a non-2xx response.
## Manifests and launch behavior
### Installed apps capture eligible links
From Chrome 139 on Windows, macOS, and Linux, with ChromeOS support pending,
eligible links open in the installed PWA whose manifest `scope` covers the
destination. They open in a browser tab if no app matches or the user opted out.
A navigation is generally eligible when it creates a new frame without opening
an auxiliary browsing context. Captured links follow launch handling configuration.
### Localized names, shortcuts, and icons
> **Prerelease (`web-app-manifest-wd-2026-05`):** This guidance may change before stable release.
Top-level `name_localized`, `short_name_localized`, and `icons_localized` take
language-tag maps. Shortcuts support those maps plus `description_localized`
and still require a base `name`. The user agent should choose the best language
match and fall back to the base member when none matches. Text entries accept
strings or objects with a `value` string and optional `lang` and `dir` overrides.
Language defaults to the map key and direction to the manifest's `dir`;
each localized icon entry is an array of image resources.
### Invalid language tags discard localized text
> **Prerelease (`web-app-manifest-spec`):** This guidance may change before stable release.
A localized text entry is discarded if its map key or explicit `lang` string is
structurally invalid. In `"fr": {"value": "Carnet", "lang": "fr_CA"}`, correct
the override to `"fr-CA"` or remove it to retain the French entry.
### Dark colors and sensitive updates
> **Prerelease (`web-app-manifest-wd-2026-05`):** This guidance may change before stable release.
With an OS dark theme, the user agent should apply valid `color_scheme_dark`
overrides for `theme_color` and `background_color`, subject to user preferences
such as accessibility settings. An omitted or invalid override leaves the
corresponding top-level color in effect.
> **Prerelease (`web-app-manifest-wd-2026-05`):** This guidance may change before stable release.
User agents should ask for express permission before changing `name`,
`short_name`, or `icons`, including localized variants, and should apply
non-sensitive changes immediately. Changing icon `src` signals an update;
checking changes at the same URL is optional. Visually insignificant changes
can be treated as non-sensitive.
### Manifest replacements and shortcut privacy
> **Prerelease (`20260813`):** This guidance may change before stable release.
Once a document has a processed manifest, the draft stops processing a
replacement whose resolved `id` differs. Use the same explicit `id` when
swapping a page's manifest link for a language-specific variant.
> **Prerelease (`20260813`):** This guidance may change before stable release.
The draft recommends letting users inspect and edit shortcut `url` values
during installation or later. Treat launch-attribution parameters as optional
and keep user identifiers out of shortcut URLs: stored URLs can survive
clearing site data.
## Installed-app detection
`navigator.getInstalledRelatedApps()` considers only the first three
`related_applications` entries. Browsers ignore `min_version` and `fingerprints`,
so verified apps can be returned with older versions or different certificates.
A same-origin page within the PWA's manifest scope can detect it on desktop
Chrome and Edge 140+ and Android Chrome 84+. Add a `webapp` entry pointing to its
own manifest. The declared or browser-computed web app ID is required on desktop
and optional on Android. Use the installation reference for native-app
verification and Android detection from outside the PWA's scope.
## Workbox registration, activation, and messages
`wb.register()` waits for window `load` by default, letting the page finish
loading before install-time precaching. Attach listeners before registration;
pass `{ immediate: true }` to start sooner.
In Workbox v6+, `wb.messageSkipWaiting()` sends `{ type: "SKIP_WAITING" }` to the
worker currently waiting on the registration even if `getSW()` selected another
worker. It has no effect before registration or with no waiting worker. A custom
worker needs to handle the message and call `self.skipWaiting()`.
`wb.messageSW(data)` uses `getSW()`. At registration it prefers a waiting worker
with the matching script URL over a matching active worker, otherwise waiting
for a matching worker to start installing. Use standalone `messageSW(sw, data)`
to target a particular worker and reply with `event.ports[0].postMessage(...)`
so the returned promise resolves.