← Back to index
class UserAgent

Constructors

🔗
UserAgent()

A representation of user agent string, which can be used to determine environmental information represented by the string. All properties are determined lazily.

import { UserAgent } from "https://deno.land/std@$STD_VERSION/http/user_agent.ts";

Deno.serve((req) => {
  const userAgent = new UserAgent(req.headers.get("user-agent") ?? "");
  return new Response(`Hello, ${userAgent.browser.name}
    on ${userAgent.os.name} ${userAgent.os.version}!`);
});

Properties

🔗
browser: Browser

The name and version of the browser extracted from the user agent string.

🔗
cpu: Cpu

The architecture of the CPU extracted from the user agent string.

🔗
device: Device

The model, type, and vendor of a device if present in a user agent string.

🔗
engine: Engine

The name and version of the browser engine in a user agent string.

🔗
os: Os

The name and version of the operating system in a user agent string.

🔗
ua: string

A read only version of the user agent string related to the instance.

Methods

🔗
[Symbol.for("Deno.customInspect")](inspect: (value: unknown) => string): string
🔗
[Symbol.for("nodejs.util.inspect.custom")](depth: number, options: any, inspect: (value: unknown, options?: unknown) => string): string
🔗
toJSON()
🔗
toString(): string