Skip to main content

Claude Prompt to Set Up a Progressive Web App (PWA)

Turn any web app into a PWA: service worker, offline support, install prompt, push notifications and app-like navigation, with a Workbox caching plan.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
Convert an existing Next.js 14 web application into a full Progressive Web App (PWA). The app is a recipe sharing and meal planning platform accessed by 25,000 monthly users. Implement the following: 1) Create the Web App Manifest (manifest.json) with: name, short_name, description, start_url with utm_source=pwa, display mode (standalone), theme_color and background_color matching the brand (theme: #16A34A, background: #FFFFFF), orientation preference, icons at sizes 48, 72, 96, 128, 144, 192, 384, and 512 pixels with maskable variants, and 3 (New Recipe, Meal Plan, Shopping List) app shortcuts for frequent actions. 2) Implement a service worker with stale-while-revalidate for pages, cache-first for assets caching strategy — use Workbox to configure: precaching for the app shell (HTML, CSS, JS, critical fonts), runtime caching for API responses with NetworkFirst with 30-second timeout fallback to cache strategy and a max-age of 24 hours, image caching with CacheFirst and size limit, and a fallback offline page. 3) Build the offline experience: detect online/offline status, queue failed POST/PUT requests in IndexedDB and retry with Background Sync when connectivity returns, show an offline indicator in the UI, and serve cached content with a "last updated" timestamp. 4) Implement the install prompt: intercept the beforeinstallprompt event, show a custom install banner after the user has saved 3 recipes or visited 5 times, track install metrics, and handle the appinstalled event to update UI. 5) Add push notifications using Web Push API with VAPID keys: request permission with a value-proposition prompt (not on first visit), handle subscription on the server, send meal plan reminders, new recipe from followed users, weekly digest notification types, and implement notification click handling with deep linking. 6) Optimize for app-like experience: add smooth page transitions with View Transitions API with slide animation, implement pull-to-refresh on mobile, handle the display-mode: standalone media query for installed-app specific styling, and manage the app window with window-controls-overlay if yes, for the desktop installed version.

What this prompt does

This prompt converts an existing [framework] web app into a full Progressive Web App. It works through the whole PWA surface in order: a Web App Manifest with proper icons and [shortcut_count] shortcuts, a service worker using a [caching_strategy] strategy via Workbox, an offline experience with Background Sync, a custom install prompt, push notifications, and app-like navigation touches. Because it sequences manifest, service worker, then offline behavior, you end up with a PWA that genuinely helps on flaky connections rather than one that just passes a checklist.

The variables tune the caching and UX tradeoffs. [caching_strategy], [api_cache_strategy], and [cache_duration] decide what is served from cache versus network and for how long, which directly shapes offline usefulness and content freshness. [install_prompt_trigger] delays the install banner until the user has shown intent rather than nagging on first visit, [push_service] and [notification_types] define re-engagement, and [transition_method] plus [use_wco] add the app-like feel for installed instances. The manifest's [display_mode] and [brand_colors] round out the installed experience so it looks like a native app rather than a browser tab.

When to use it

  • Making an existing app installable on home screens and the desktop.
  • Adding offline support so users keep working through flaky or absent connectivity.
  • Queuing failed writes and replaying them with Background Sync when connectivity returns.
  • Designing a value-first install prompt instead of nagging on first visit.
  • Adding push notifications for re-engagement with clear permission timing.
  • Giving installed instances app-like navigation, transitions, and window controls.

Example output

You get a PWA implementation plan with code: a manifest.json with name fields, [display_mode], theme and background colors from [brand_colors], a full icon set with maskable variants, and [shortcut_count] shortcuts; a Workbox service worker doing app-shell precaching plus runtime caching with [api_cache_strategy] and a [cache_duration] max-age; offline detection with IndexedDB-queued writes and Background Sync; a beforeinstallprompt handler firing after [install_prompt_trigger]; push setup via [push_service] for [notification_types]; and app-like touches using [transition_method].

Pro tips

  • Match [caching_strategy] to content type: stale-while-revalidate suits pages, cache-first suits static assets, network-first suits fresh API data.
  • Keep [cache_duration] honest; long durations boost offline reach but risk serving stale content, so pair it with a visible last-updated timestamp.
  • Delay the install banner until [install_prompt_trigger] is met; prompting on first visit tanks acceptance rates.
  • Request push permission with a value proposition, never on first load, or users will permanently deny [notification_types].
  • Generate every icon size with maskable variants; missing sizes cause ugly cropping on some platforms.
  • Treat [use_wco] window-controls-overlay as desktop polish and feature-detect it rather than assuming support.
  • Show a last-updated timestamp alongside cached content so users on the offline path know how fresh what they are seeing actually is.

Frequently Asked Questions

Does turning my app into a PWA require rewriting it?
No. The prompt layers PWA capabilities onto an existing `[framework]` app: a manifest, a service worker, and offline handling. Your core application logic stays intact, though you may refactor data writes to support the Background Sync queue for true offline resilience.
How does offline support handle failed form submissions?
Failed POST and PUT requests are queued in IndexedDB and retried with Background Sync once connectivity returns. This means a user can submit while offline and have the action complete later, rather than silently losing the data they entered.
When should the install prompt appear?
After `[install_prompt_trigger]` is satisfied, such as several visits or a meaningful action, not on first load. Showing it once the user has experienced value dramatically improves acceptance, and the prompt intercepts `beforeinstallprompt` to control this timing.
Are push notifications guaranteed to work everywhere?
No. Push support via `[push_service]` varies by browser and platform, and iOS only supports web push for installed PWAs in recent versions. The prompt requests permission with a value proposition, but you should treat push as an enhancement, not a guarantee.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Frontend Development Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support