react-pwa-hazhtech
Version:
A React library for Progressive Web App (PWA) functionality with install prompts and status tracking
40 lines (36 loc) • 1.25 kB
text/typescript
import React from 'react';
interface PWAContextProps {
isInstalled: boolean;
isInstallable: boolean;
promptInstall: () => Promise<{
outcome: 'accepted' | 'dismissed';
} | null>;
installPromptEvent: BeforeInstallPromptEvent | null;
isStandalone: boolean;
}
declare const PWAContext: React.Context<PWAContextProps>;
declare global {
interface WindowEventMap {
beforeinstallprompt: BeforeInstallPromptEvent;
appinstalled: Event;
}
interface BeforeInstallPromptEvent extends Event {
prompt: () => Promise<void>;
userChoice: Promise<{
outcome: 'accepted' | 'dismissed';
}>;
}
}
interface PWAProviderProps {
children: React.ReactNode;
onInstallPromptAvailable?: (event: BeforeInstallPromptEvent) => void;
onAppInstalled?: () => void;
}
declare const PWAProvider: React.FC<PWAProviderProps>;
declare const triggerPWAInstall: () => Promise<{
outcome: "accepted" | "dismissed";
} | null>;
declare const isPWAInstallAvailable: () => boolean;
declare const isPWAMode: () => boolean;
declare const usePWA: () => PWAContextProps;
export { PWAContext, type PWAContextProps, PWAProvider, isPWAInstallAvailable, isPWAMode, triggerPWAInstall, usePWA };