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

solo-analytics

v0.1.1

Published

A comprehensive browser analytics library with TypeScript support

Downloads

1

Readme

📊 Solo Analytics

A lightweight TypeScript library for comprehensive browser and device information collection with a clean API surface.

npm version TypeScript License: MIT Bundle Size

Features

  • 🔍 Extensive browser, OS, and device detection with full TypeScript support
  • 📱 Precise mobile, tablet, and desktop device classification
  • 🌐 Network connectivity and performance data
  • 📏 Screen and viewport dimensions with orientation detection
  • ⚡ Comprehensive performance metrics (navigation, timing, memory)
  • 🌍 Locale, timezone, and environment information
  • ⚙️ Advanced feature detection (camera, microphone, battery, etc.)
  • 🔒 Incognito/private mode detection
  • 🔄 Auto-refresh capability for dynamic metrics

Installation

npm install solo-analytics

Basic Usage

import { useSoloAnalytics } from "solo-analytics";

// Initialize with default options
const analytics = useSoloAnalytics();

// Access common properties
console.log("Mobile device:", analytics.isMobile);
console.log("Browser:", analytics.browserName);
console.log("OS:", analytics.osName);

// Access the complete data object
console.log("Full analytics data:", analytics.data);

Configuration Options

import { useSoloAnalytics } from "solo-analytics";

const analytics = useSoloAnalytics({
  // Automatically refresh dynamic data (network, performance)
  autoRefresh: true,
  // Refresh interval in milliseconds (default: 30000)
  refreshInterval: 10000,
  // Track page visibility changes
  trackVisibility: true,
});

API Reference

The useSoloAnalytics() function returns an object with the following methods and properties:

Methods

  • refresh(): Manually triggers a refresh of all analytics data
  • destroy(): Cleans up all event listeners and timers to prevent memory leaks

Convenience Properties

  • isMobile: Whether the device is a mobile phone
  • isTablet: Whether the device is a tablet
  • isDesktop: Whether the device is a desktop computer
  • isOnline: Current network connection state
  • isVisible: Whether the page is currently visible
  • browserName: The name of the browser
  • osName: The name of the operating system

Complete Data

  • data: An object containing all detailed analytics information

Data Structure

The data object contains the following structure:

interface SoloAnalyticsInfo {
  browser: {
    name: string;
    version: string;
    major: string;
    userAgent: string;
    vendor: string;
    engine: string;
    engineVersion: string;
  };
  os: {
    name: string;
    version: string;
    architecture: string;
  };
  device: {
    type: "mobile" | "tablet" | "desktop" | "unknown";
    vendor: string;
    model: string;
    orientation: "portrait" | "landscape";
    isMobile: boolean;
    isTablet: boolean;
    isDesktop: boolean;
    touch: boolean;
  };
  network: {
    online: boolean;
    effectiveType: string;
    downlink: number;
    rtt: number;
    saveData: boolean;
  };
  screen: {
    width: number;
    height: number;
    availWidth: number;
    availHeight: number;
    colorDepth: number;
    orientation: string;
    pixelRatio: number;
    touchPoints: number;
  };
  performance: {
    memory: {
      jsHeapSizeLimit: number;
      totalJSHeapSize: number;
      usedJSHeapSize: number;
    } | null;
    navigation: {
      type: string;
      redirectCount: number;
    };
    timing: {
      loadTime: number;
      domContentLoaded: number;
      firstPaint: number | null;
      firstContentfulPaint: number | null;
    };
  };
  location: {
    timeZone: string;
    language: string;
    languages: string[];
    isRestricted: boolean;
    doNotTrack: boolean | null;
    cookiesEnabled: boolean;
    localStorage: boolean;
    sessionStorage: boolean;
  };
  pageVisibility: "visible" | "hidden";
  referrer: string;
  isIncognito: boolean;
  hasCamera: boolean | null;
  hasMicrophone: boolean | null;
  hasBattery: boolean | null;
  batteryLevel: number | null;
  batteryCharging: boolean | null;
  permissions: Record<string, string>;
}

Framework Integration Examples

React

import { useEffect, useState } from "react";
import { useSoloAnalytics, SoloAnalyticsReturn } from "solo-analytics";

function DeviceInfo() {
  const [analytics, setAnalytics] = useState<SoloAnalyticsReturn | null>(null);

  useEffect(() => {
    // Initialize on the client side
    const analyticsInstance = useSoloAnalytics();
    setAnalytics(analyticsInstance);

    // Cleanup on unmount
    return () => {
      analyticsInstance.destroy();
    };
  }, []);

  if (!analytics) return <div>Loading...</div>;

  return (
    <div>
      <h1>Device Information</h1>
      <p>
        Type:{" "}
        {analytics.isMobile
          ? "Mobile"
          : analytics.isTablet
          ? "Tablet"
          : "Desktop"}
      </p>
      <p>Browser: {analytics.browserName}</p>
      <p>Operating System: {analytics.osName}</p>
      <p>Network Status: {analytics.isOnline ? "Online" : "Offline"}</p>
    </div>
  );
}

Vue 3

<template>
  <div>
    <h1>Device Information</h1>
    <p>Type: {{ deviceType }}</p>
    <p>Browser: {{ analytics.browserName }}</p>
    <p>Operating System: {{ analytics.osName }}</p>
    <p>Network Status: {{ analytics.isOnline ? "Online" : "Offline" }}</p>
  </div>
</template>

<script setup lang="ts">
import { onMounted, onUnmounted, ref, computed } from "vue";
import { useSoloAnalytics, SoloAnalyticsReturn } from "solo-analytics";

const analytics = ref<SoloAnalyticsReturn | null>(null);

onMounted(() => {
  analytics.value = useSoloAnalytics({
    trackVisibility: true,
  });
});

onUnmounted(() => {
  analytics.value?.destroy();
});

const deviceType = computed(() => {
  if (!analytics.value) return "Unknown";

  if (analytics.value.isMobile) return "Mobile";
  if (analytics.value.isTablet) return "Tablet";
  return "Desktop";
});
</script>

Nuxt 3

<template>
  <div>
    <h1>Device Information</h1>
    <div v-if="analytics">
      <p>Type: {{ deviceType }}</p>
      <p>Browser: {{ analytics.browserName }}</p>
      <p>Operating System: {{ analytics.osName }}</p>
      <p>Network Status: {{ analytics.isOnline ? "Online" : "Offline" }}</p>
    </div>
    <div v-else>
      <p>Loading device information...</p>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from "vue";
import { useSoloAnalytics, SoloAnalyticsReturn } from "solo-analytics";

const analytics = ref<SoloAnalyticsReturn | null>(null);

// Important: Only initialize on client-side to avoid SSR issues
onMounted(() => {
  analytics.value = useSoloAnalytics({
    trackVisibility: true,
    autoRefresh: true,
    refreshInterval: 15000,
  });
});

onBeforeUnmount(() => {
  if (analytics.value) {
    analytics.value.destroy();
  }
});

const deviceType = computed(() => {
  if (!analytics.value) return "Unknown";

  if (analytics.value.isMobile) return "Mobile";
  if (analytics.value.isTablet) return "Tablet";
  return "Desktop";
});
</script>

Vanilla JavaScript

<script type="module">
  import { useSoloAnalytics } from "solo-analytics";

  document.addEventListener("DOMContentLoaded", () => {
    const analytics = useSoloAnalytics();

    // Display information on the page
    document.getElementById("deviceType").textContent = analytics.isMobile
      ? "Mobile"
      : analytics.isTablet
      ? "Tablet"
      : "Desktop";

    document.getElementById(
      "browserInfo"
    ).textContent = `${analytics.browserName} on ${analytics.osName}`;

    // Cleanup on window close
    window.addEventListener("beforeunload", () => {
      analytics.destroy();
    });
  });
</script>

Browser Compatibility

Solo Analytics is compatible with all modern browsers, including:

  • Chrome 60+
  • Firefox 55+
  • Safari 11+
  • Edge 16+
  • Opera 47+
  • iOS Safari 11+
  • Android Browser 67+

Some advanced features may not be available in older browsers but the library includes graceful fallbacks.

Development

# Install dependencies
npm install

# Run development server
npm run dev

# Build for production
npm run build

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Repository

GitHub: https://github.com/cesswhite/solo-analytics

License

MIT License

Copyright (c) 2025 Céss White

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.