mazey
    Preparing search index...

    Function isSafePWAEnv

    • Detect whether the current browser document provides the minimum JavaScript-detectable prerequisites for PWA functionality.

      This function checks for a secure context, Service Worker API support, and, by default, a web app manifest link with a non-empty href. Options can make the manifest optional or require the current path to be within a same-origin scope.

      It does not validate or request the manifest, verify service worker registration, determine whether the app is installed, or guarantee that an installation prompt is available. Browser-specific installation policies may impose additional requirements.

      Usage:

      import { isSafePWAEnv } from "mazey";

      const ret = isSafePWAEnv();
      console.log(ret);

      Output:

      true
      

      Callers that already own browser references can inject them without changing globals:

      const ret = isSafePWAEnv({
      scope: "/app/",
      environment: { window, navigator, document },
      });

      Parameters

      • options: IsSafePWAEnvOptions = {}

        Optional manifest, URL-scope, and browser-environment requirements.

      Returns boolean

      Whether the detectable minimum PWA prerequisites are satisfied.

      Browser-preferred and safe to call during SSR. When environment is provided, only those objects are inspected; missing injected capabilities return false rather than falling back to globals.