mazey
    Preparing search index...

    Function detectVisitorType

    • Classify a visitor using conservative browser-side heuristics.

      Classification checks known crawler and automated-fetcher user-agent tokens first. It then checks explicit browser-automation user-agent tokens and navigator.webdriver === true. All other visitors return "unknown".

      "unknown" means that no supported signal was detected. It does not verify that the visitor is human. User-agent values can be modified or spoofed, and automation signals can be hidden, modified, or unavailable. Both false positives and false negatives are possible.

      Usage:

      import { detectVisitorType } from "mazey";

      const visitorType = detectVisitorType();
      console.log(visitorType);

      Possible output:

      unknown
      

      Explicit user-agent:

      const visitorType = detectVisitorType(
      "Mozilla/5.0 (compatible; Googlebot/2.1)"
      );

      console.log(visitorType);

      Output:

      crawler
      

      Parameters

      • OptionaluserAgent: string

        Optional user-agent string. Defaults to navigator.userAgent when available. An explicit value replaces only the user-agent source; the current browser's WebDriver signal is still checked.

      Returns VisitorType

      "crawler", "automation", or "unknown", in that priority.

      If an explicitly supplied user agent is not a string.

      Safe during SSR and in Node.js. This is a heuristic classification utility, not human verification, crawler authentication, or a security boundary. Do not use it by itself for authentication, authorization, payments, rate limiting, fraud prevention, access control, or security-sensitive content. Genuine crawler verification generally requires server-side request information and provider-specific validation.