Add an install prompt to Astro
To add an install prompt on Astro, paste the InstantPWA snippet into src/layouts/BaseLayout.astro via BaseLayout.astro <head>. The popup captures the browser's native install signal where supported and falls back to a guided walkthrough on iOS Safari, so every visitor sees a clear path to installing your Astro site as an app.
Steps
- 1
Open src/layouts/BaseLayout.astro
Go to BaseLayout.astro <head>.
- 2
Paste the InstantPWA snippet
Drop the one-line async script tag in the Astro head section — no build step or dependency install.
- 3
Configure the trigger
In your InstantPWA dashboard, set when the popup appears — on page load, after N seconds, or after a scroll/engagement threshold.
- 4
Publish
Save/publish in Astro so the change goes live — most builders require an explicit publish step before custom code runs.
- 5
Verify on a phone
Open your live Astro URL on a mobile device (not the editor preview) to confirm the popup renders.
Constraints to know
- Astro ships zero JS by default (the 'islands' architecture), so InstantPWA is often the only client-side script on the page — it doesn't need a hydration directive like client:load.
- If you use Astro's View Transitions (astro:transitions), the <head> persists across client-side navigations, so the snippet keeps its state instead of re-running per page.
FAQ
Does the install prompt work on iOS Astro visitors?+
iOS Safari never fires the native beforeinstallprompt event, so InstantPWA shows a share-sheet walkthrough instead — visitors still get a clear add-to-home-screen path.
Will this conflict with other scripts on my site?+
No — InstantPWA is a single first-party async script with no third-party dependencies, so it doesn't block or compete with analytics or chat widgets.
Do I need to touch anything else in Astro besides BaseLayout.astro <head>?+
No — the head snippet is the only integration point; InstantPWA hosts the manifest and service worker for you.