From 89d580b90d3e13e13a974209e4c0ffbab831e7c0 Mon Sep 17 00:00:00 2001 From: Linus Rath Date: Fri, 10 Apr 2026 14:20:48 +0200 Subject: [PATCH] feat: add don't remind me again option to install prompt for PWA --- components/pwa-install-prompt.tsx | 37 ++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/components/pwa-install-prompt.tsx b/components/pwa-install-prompt.tsx index 727d69c8..c5ac68c9 100644 --- a/components/pwa-install-prompt.tsx +++ b/components/pwa-install-prompt.tsx @@ -8,12 +8,16 @@ interface BeforeInstallPromptEvent extends Event { userChoice: Promise<{ outcome: "accepted" | "dismissed" }>; } +const DISMISSED_KEY = "pwa-install-dismissed"; + export function PWAInstallPrompt() { const [deferredPrompt, setDeferredPrompt] = useState(null); const [showPrompt, setShowPrompt] = useState(false); useEffect(() => { + if (localStorage.getItem(DISMISSED_KEY)) return; + const handler = (e: Event) => { e.preventDefault(); setDeferredPrompt(e as BeforeInstallPromptEvent); @@ -43,6 +47,11 @@ export function PWAInstallPrompt() { setShowPrompt(false); }; + const handleDismissForever = () => { + localStorage.setItem(DISMISSED_KEY, "1"); + setShowPrompt(false); + }; + if (!showPrompt || !deferredPrompt) { return null; } @@ -69,18 +78,26 @@ export function PWAInstallPrompt() { -
+
+
+ + +
-