is-incognito-mode - v2.3.0
    Preparing search index...

    Interface DetectIncognitoOptions

    Options for detectIncognito.

    interface DetectIncognitoOptions {
        globals?: DetectionGlobals;
        privateQuotaThresholdBytes?: number;
        signal?: AbortSignal;
        timeoutMs?: number;
    }
    Index

    Properties

    Override the global navigator / window / indexedDB lookups. Used in tests; in production the live globals are used.

    privateQuotaThresholdBytes?: number

    Advanced override. The Chromium strategy classifies a tab as private when its storage headroom (estimate().quota - estimate().usage) is below this many bytes. Defaults to 9.5 GiB — the midpoint between the 10 GiB headroom Chrome reports for a normal tab and the 9 GiB it reports for an incognito tab.

    Only change this if you have measured your audience.

    signal?: AbortSignal

    An AbortSignal that cancels detection. If it is already aborted when detectIncognito is called, the call rejects synchronously; if it aborts while a probe is running, the probe is abandoned. Either way the rejection is an IncognitoDetectionError with code: 'ABORTED'.

    Pair it with a component lifecycle so a verdict that arrives after the user has navigated away is discarded.

    const controller = new AbortController();
    onCleanup(() => controller.abort());
    await detectIncognito({ signal: controller.signal });
    timeoutMs?: number

    Maximum time, in milliseconds, to wait for a verdict. If detection has not settled by the deadline it rejects with an IncognitoDetectionError whose code is 'TIMEOUT', and any in-flight storage probe is abandoned.

    Defaults to undefinedno deadline (legacy behaviour). Because a storage probe can, in rare browser states, stall indefinitely (e.g. a Firefox indexedDB.open request that never fires success/error), passing a bound such as 5000 is recommended on any critical render path (paywalls, analytics gates) so a stalled probe can never freeze the calling code.

    await detectIncognito({ timeoutMs: 5000 });