user-agent utility module wraps ua-parser-js to provide clean, type-safe user-agent parsing and a React component for compact display in tables and session lists.
Installation
The user-agent utilities are part of@apollo-deploy/components:
Parsing user-agent strings
parseUserAgent()
Parses a user-agent string into a flat, easy-to-use object. Results are cached per unique UA string for performance.
null or undefined returns an empty result (all fields undefined):
ParsedUserAgent type
Individual accessors
For cases where you only need a specific piece of information, use the individual accessor functions. These avoid parsing fields you don’t need.ua is null or undefined, each accessor returns a stub object with is() returning false and toString() returning "".
Raw access
parseUserAgentRaw()
Returns the full raw IResult from ua-parser-js (nested objects):
null when ua is null or undefined.
Human-readable formatters
Convenience functions that return ready-to-display labels:"Unknown" when the UA is null/undefined or cannot be parsed.
UserAgentDisplay — Display component
A React component for rendering user-agent information in a consistent format, designed for use in tables, cards, and session lists.
Props
Layout examples
Stack variant (default):Cache management
The parser caches results per unique UA string. UseclearUserAgentCache() to reset the cache (useful for testing or memory management):
Type reference
Types re-exported fromua-parser-js: