npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cic-it-nancy/browser-information

v1.0.2

Published

A lightweight, universal browser information reader for JavaScript and TypeScript applications.

Readme

Browser Information

A lightweight, universal browser information reader for JavaScript and TypeScript applications.

@cic-it-nancy/browser-information provides a safe and structured way to retrieve client-side environment data, screen metrics, hardware capabilities, and storage estimates, with built-in fallbacks when running in unsupported environments or during server-side rendering (SSR).


Features

  • Safe Extraction: Gracefully handles missing browser APIs without throwing unhandled exceptions.
  • Hardware & Environment Insights: Collects device memory, CPU core concurrency, screen resolution (accounting for a device pixel ratio), and viewport dimensions.
  • Asynchronous Storage Metrics: Supports retrieval of storage quota and usage estimates via navigator.storage.estimate().
  • Customisable Logging: Built-in logger with options to silence output or plug in custom logging handlers.
  • TypeScript First: Full type definitions included out of the box.
  • Multi-Format Distribution: Supports ESM, CommonJS, and standalone browser bundles (browser.js / browser.min.js).

Installation

Install the package using your preferred package manager:

# Using npm
npm install @cic-it-nancy/browser-information

# Using pnpm
pnpm add @cic-it-nancy/browser-information

# Using Yarn
yarn add @cic-it-nancy/browser-information

Quick Start

Basic Synchronous Usage

Synchronous metrics (screen resolution, user agent, hardware concurrency, etc.) are gathered upon instantiation:

import {BrowserInformationReader} from '@cic-it-nancy/browser-information';

const reader = new BrowserInformationReader();

// Access individual properties
console.log('User Agent:', reader.getUserAgent());
console.log('Hardware Concurrency:', reader.getHardwareConcurrency());
console.log('Screen Resolution:', reader.getScreenResolution()); // [width, height]

// Export as a plain JavaScript object
const info = reader.toJson();
console.log(info);

// Format as a human-readable string
console.log(reader.toString());

Collecting Asynchronous Data

Some browser metrics, such as storage quota estimates, require an asynchronous call:

import {BrowserInformationReader} from '@cic-it-nancy/browser-information';

async function collectBrowserDetails() {
    const reader = new BrowserInformationReader();

    // Fetch asynchronous metrics (e.g., storage estimation)
    await reader.readAsyncData();

    const storage = reader.getStorageEstimate();
    if (storage) {
        console.log(`Quota: ${storage.quota} bytes`);
        console.log(`Usage: ${storage.usage} bytes`);
    }

    console.log(reader.toJson());
}

collectBrowserDetails();

Logger Configuration

The library includes a configurable logging utility to help diagnose issues when APIs are inaccessible.

Silencing Logs

To suppress all debug logs emitted by the reader:

import {Logger} from '@cic-it-nancy/browser-information';

Logger.setSilent(true);

Custom Logger Function

You can route log messages through your own logging infrastructure (e.g. Winston, Pino, or a custom wrapper):

import {Logger} from '@cic-it-nancy/browser-information';

Logger.setLogger((...args: unknown[]) => {
    // Custom log dispatching logic
    console.info('[BrowserInfo]', ...args);
});

API Reference

BrowserInformationReader

Methods

| Method | Return Type | Description | |:---------------------------|:---------------------------------|:--------------------------------------------------------------------------------------| | constructor() | BrowserInformationReader | Initialises the reader and gathers all available synchronous data. | | readAsyncData() | Promise<void> | Gathers asynchronous data (such as storage quota and usage). | | getUserAgent() | string \| undefined | Returns the navigator.userAgent string. | | getWebdriver() | boolean \| undefined | Indicates whether the browser is controlled by automation (e.g. Selenium, Puppeteer). | | getScreenResolution() | [number, number] \| undefined | Physical screen resolution [width, height], adjusted for devicePixelRatio. | | getInnerResolution() | [number, number] \| undefined | Viewport dimensions [innerWidth, innerHeight]. | | getDeviceMemory() | number \| undefined | Approximate device RAM in gigabytes (where supported). | | getHardwareConcurrency() | number \| undefined | Number of logical processor cores available. | | getLanguage() | string \| undefined | User's preferred browser language (e.g. 'en-GB'). | | getStorageEstimate() | StorageEstimate \| undefined | Estimated quota and usage details (available after readAsyncData()). | | toJson() | BrowserInformationReaderResult | Returns a key-value object containing only defined values. | | toString() | string | Formats all gathered data into a multi-line human-readable string. |


BrowserInformationReaderResult (TypeScript Interface)

interface BrowserInformationReaderResult {
    UserAgent?: string;
    Webdriver?: boolean;
    ScreenResolution?: [number, number];
    InnerResolution?: [number, number];
    DeviceMemory?: number;
    HardwareConcurrency?: number;
    SystemLanguage?: string;
    StorageEstimate?: StorageEstimate;
}

Logger

| Method | Parameters | Description | |:------------------------|:---------------------------|:--------------------------------------------------------------------------| | log(...data) | ...any[] | Dispatches log arguments to the active logger if silent mode is disabled. | | setSilent(silentMode) | boolean | Enables or disables library log output. | | setLogger(logger) | (...data: any[]) => void | Replaces the default console.debug logger with a custom function. |


Browser Standalone Usage

Pre-bundled versions are available under the lib/ directory for direct script inclusion:


<script src="node_modules/@cic-it-nancy/browser-information/lib/browser.min.js"></script>

Authors & Contributors

  • CIC-IT Nancy — Author
  • Pierre 'AlasDiablo' M (GitHub) — Contributor

Licence

GNU Lesser General Public License v3.0 (LGPL-3.0).