const { getUserAgent } = require("universal-user-agent"); // or import { getUserAgent } from "universal-user-agent"; const userAgent = getUserAgent(); // userAgent will look like this // in browser: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0" // in node: Node.js/v8.9.4 (macOS High Sierra; x64)
The Node implementation was originally inspired by default-user-agent.