scooter

API v8.0.x

Installation:

npm: npm install @hapi/scooter

yarn: yarn add @hapi/scooter

Scooter uses the my-ua-parser package to provide user-agent information. For more details of what information scooter provides, please see the my-ua-parser documentation.

request.userAgent()

A convenience decoration added to every request. Returns the same parsed user-agent object as request.plugins.scooter.

// Both are equivalent
request.userAgent()
request.plugins.scooter

The returned object has the following shape:

{
    family: string,       // browser name, e.g. 'Chrome'
    major:  string,       // major version, e.g. '91'
    minor:  string,       // minor version, e.g. '0'
    patch:  string,       // patch version, e.g. '4472'
    source: string,       // original user-agent header value
    os: {
        family: string,   // OS name, e.g. 'Windows'
        major:  string,
        minor:  string,
        patch:  string
    },
    device: {
        family: string,   // device model or type, e.g. 'iPhone'
        brand:  string,   // device vendor, e.g. 'Apple'
        model:  string    // device model, e.g. 'iPhone'
    }
}

Unknown values default to 'Other' for family fields and '0' for version fields.

clipboard