UNPKG

use-pwa

Version:

React hook for PWA installation detection and handling

27 lines (25 loc) 674 B
type UserChoice = { outcome: "accepted" | "dismissed"; platform: string; }; interface BeforeInstallPromptEvent extends Event { readonly platforms: string[]; readonly userChoice: Promise<UserChoice>; prompt(): Promise<void>; } declare global { interface WindowEventMap { beforeinstallprompt: BeforeInstallPromptEvent; } interface Navigator { standalone?: boolean; } } type PwaData = { canInstall: boolean; install: () => Promise<UserChoice | undefined>; isInstalled: boolean; isSupported: boolean; }; declare function usePwa(): PwaData; export { type PwaData, type UserChoice, usePwa as default, usePwa };