@nrz/user-agent
v1.0.0
Published
The User-Agent string that nrz sends with every outbound request
Readme
@nrz/user-agent
The User-Agent string that nrz sends with every outbound request.
Overview
Every place in the client that talks to a registry or an API sends the
same User-Agent, and lifecycle scripts see the same value in
npm_config_user_agent. This package is the single source of that
string so the various clients cannot drift apart.
The value is the nrz version followed by the runtime, which is taken
from navigator.userAgent when one is available, and otherwise
detected from process.versions.
This package has no dependencies and touches no node builtins, so it
is safe to use from browser-safe packages such as @nrz/query.
Usage
import { userAgent, userAgentHeaders } from '@nrz/user-agent'
console.log(userAgent) // nrz/1.0.10 Node.js/22.22.0
// `userAgentHeaders` is `{ 'User-Agent': userAgent }` in Node.js, Bun and
// Deno, and `{}` in a browser, where the header cannot be set by scripts
// and would otherwise force a CORS preflight on cross-origin requests.
await fetch(url, {
headers: { Accept: 'application/json', ...userAgentHeaders },
})