mcpField
P
pwa

pwa

github.com/claude-dev-suiteDevelopment4642 installsUpdated 2d ago
Repository

About pwa

A reference skill for building Progressive Web Apps, aimed at developers implementing installable web apps with offline behavior. It outlines manifests, Workbox service workers, caching strategies, and install prompts.

Key features

  1. 01Web App Manifest setup
  2. 02Workbox service worker patterns
  3. 03Offline fallback handling
  4. 04Caching strategy selection
  5. 05Install prompt handling
  6. 06Production readiness checklist

Use cases

  1. 01Adding offline access to a web app
  2. 02Caching static assets and dynamic data appropriately
  3. 03Implementing an app installation prompt

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/claude-dev-suite/claude-dev-suite --skill pwa

After installing, type/pwain Claude Code to confirm it loaded.

Details

From the project README

Progressive Web Apps

Web App Manifest

{
  "name": "My App",
  "short_name": "MyApp",
  "start_url": "/",
  "display": "standalone",
  "background_color": "#ffffff",
  "theme_color": "#000000",
  "icons": [
    { "src": "/icons/192.png", "sizes": "192x192", "type": "image/png" },
    { "src": "/icons/512.png", "sizes": "512x512", "type": "image/png", "purpose": "any maskable" }
  ]
}
<link rel="manifest" href="/manifest.json" />
<meta name="theme-color" content="#000000" />
<link rel="apple-touch-icon" href="/icons/192.png" />

Service Worker (Workbox — recommended)

// sw.ts (using Workbox)
import { precacheAndRoute } from 'workbox-precaching';
import { registerRoute } from 'workbox-routing';
import { CacheFirst, NetworkFirst, StaleWhileRevalidate } from 'workbox-strategies';
import { ExpirationPlugin } from 'workbox-expiration';

// Precache app shell
precacheAndRoute(self.__WB_MANIFEST);

// Cache-first for static assets
registerRoute(
  ({ request }) => request.destination === 'image' || request.destination === 'font',
  new CacheFirst({
    cacheName: 'static-assets',
    plugins: [new ExpirationPlugin({ maxEntries: 100, maxAgeSeconds: 30 * 24 * 60 * 60 })],
  })
);

// Network-first for API calls
registerRoute(
  ({ url }) => url.pathname.startsWith('/api/'),
  new NetworkFirst({
    cacheName: 'api-cache',
    plugins: [new ExpirationPlugin({ maxEntries: 50, maxAgeSeconds: 5 * 60 })],
  })
);

// Stale-while-revalidate for pages
registerRoute(
  ({ request }) => request.mode === 'navigate',
  new StaleWhileRevalidate({ cacheName: 'pages' })
);

Registration

if ('serviceWorker' in navigator) {
  window.addEventListener('load', async () => {
    const registration = await navigator.serviceWorker.register('/sw.js');
    console.log('SW registered:', registration.scope);
  });
}

Offline Fallback

// In service worker
import { setCatchHandler } from 'workbox-routing';

setCatchHandler(async ({ event }) => {
  if (event.request.destination === 'document') {
    return caches.match('/offline.html');
  }
  return Response.error();
});

Caching Strategies

StrategyUse ForFreshness
Cache FirstStatic assets, fonts, imagesStale OK
Network FirstAPI data, dynamic pagesFresh preferred
Stale While RevalidateSemi-dynamic contentStale, updating
Network OnlyAuth, POST requestsAlways fresh
Cache OnlyPrecached app shellImmutable

Install Prompt

let deferredPrompt: BeforeInstallPromptEvent | null = null;

window.addEventListener('beforeinstallprompt', (e) => {
  e.preventDefault();
  deferredPrompt = e;
  showInstallButton();
});

async function installApp() {
  if (!deferredPrompt) return;
  deferredPrompt.prompt();
  const { outcome } = await deferredPrompt.userChoice;
  console.log(`Install ${outcome}`);
  deferredPrompt = null;
}

Anti-Patterns

Anti-PatternFix
Caching everything with Cache FirstUse Network First for dynamic data
No offline fallback pagePrecache an offline.html
No cache expirationUse ExpirationPlugin with maxEntries/maxAge
SW caches auth tokensNever cache sensitive data
No SW update strategyUse skipWaiting() + prompt user to refresh

Production Checklist

  • Web App Manifest with icons and theme
  • Service worker with Workbox strategies
  • Offline fallback page
  • Cache expiration policies
  • Install prompt UX
  • Lighthouse PWA audit passing

Comments

Markdown supported