txiki.js icon indicating copy to clipboard operation
txiki.js copied to clipboard

Implement `navigator.userAgentData` as a built-in API

Open jimmywarting opened this issue 7 months ago • 1 comments

I’d like to suggest implementing navigator.userAgentData as a built-in global API.

This would help bring better support for web-standard APIs and improve feature parity between browser and runtime environments. It's especially useful in universal (isomorphic) codebases where one shouldn't have to rely on environment-specific globals like process, or check for the presence of Deno or Bun in globalThis.

Having navigator.userAgentData built in would provide a clean and consistent way to detect key runtime details such as:

  • the brand (e.g. Deno, Bun, Node)
  • the version of the runtime
  • the platform (e.g. macOS, Windows, Linux, etc.)

This would be highly useful in scenarios where server-side code needs to branch based on the environment but still adhere to web platform standards. It removes the need for runtime-specific APIs like process.version or string parsing from user agent headers.

Please consider supporting this as a native part of the runtime.

jimmywarting avatar May 28 '25 19:05 jimmywarting

Makes sense! If you're up for it a PR would be welcome!

saghul avatar Sep 01 '25 09:09 saghul