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

@danielgtmn/umami-react

v1.1.6

Published

The Umami Analytics Loader is a lightweight script that enables you to easily integrate Umami Analytics into your website. Umami is a simple, open-source website analytics tool that provides valuable insights into your website's traffic without compromisi

Readme

React Umami Analytics

A lightweight React component for Umami Analytics — the privacy-focused, open-source alternative to Google Analytics.

Zero runtime dependencies. Full TypeScript support. Works with React 18.2+ and 19.

Installation

pnpm add @danielgtmn/umami-react

Quick Start

import UmamiAnalytics from '@danielgtmn/umami-react';

function App() {
  return (
    <>
      <UmamiAnalytics
        url="https://analytics.example.com"
        websiteId="your-website-id"
      />
      {/* Your app content */}
    </>
  );
}

The component renders nothing — it only injects the Umami tracking script.

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | url | string | UMAMI_URL env var | Your Umami instance URL | | websiteId | string | UMAMI_ID env var | Your website tracking ID | | debug | boolean | false | Log debug info to console | | lazyLoad | boolean | false | Load script on first user interaction | | onlyInProduction | boolean | true | Skip loading in development | | domains | string[] | — | Restrict tracking to specific domains | | scriptAttributes | Record<string, string> | — | Additional <script> attributes |

All props can also be set via environment variables:

UMAMI_URL=https://analytics.example.com
UMAMI_ID=your-website-id
UMAMI_DEBUG=false
UMAMI_LAZY_LOAD=true

Event Tracking

Use the useUmami hook for custom events, pageviews, and user identification:

import { useUmami } from '@danielgtmn/umami-react';

function MyComponent() {
  const { track, trackPageview, identify } = useUmami();

  return (
    <button onClick={() => track('signup', { plan: 'pro' })}>
      Sign up
    </button>
  );
}

Hook API

const {
  track,                 // track(eventName, eventData?)
  trackPageview,         // trackPageview(pageviewData?)
  trackPageviewWithUTM,  // trackPageviewWithUTM(utmParams, additionalData?)
  trackPageviewAsync,    // trackPageviewAsync(utmId, fetcherFn, additionalData?)
  identify,              // identify(userId) or identify(sessionData)
} = useUmami();

Pageview with UTM Parameters

const { trackPageviewWithUTM } = useUmami();

trackPageviewWithUTM({
  utm_source: 'newsletter',
  utm_medium: 'email',
  utm_campaign: 'spring-sale',
});

Async UTM Fetching

Fetch UTM parameters from your backend before tracking:

import { useUmami, UTMFetcher } from '@danielgtmn/umami-react';

const fetchUTM: UTMFetcher = async (utmId) => {
  const res = await fetch(`/api/utm/${utmId}`);
  return res.json();
};

// Fetches UTM data, then tracks the pageview
// Falls back to basic pageview if the fetch fails
await trackPageviewAsync('campaign-123', fetchUTM);

User Identification

const { identify } = useUmami();

// With a string ID
identify('user-123');

// With session data
identify({ userId: 'user-123', plan: 'pro' });

// Both
identify('user-123', { plan: 'pro' });

Disabling Auto-Tracking

To manually control pageview tracking, disable Umami's auto-tracking:

<UmamiAnalytics
  url="https://analytics.example.com"
  websiteId="your-website-id"
  scriptAttributes={{ 'data-auto-track': 'false' }}
/>

Framework Examples

Next.js (App Router)

// app/layout.tsx
import UmamiAnalytics from '@danielgtmn/umami-react';

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        <UmamiAnalytics
          url="https://analytics.example.com"
          websiteId="your-website-id"
        />
        {children}
      </body>
    </html>
  );
}

Vite

// src/App.tsx
import UmamiAnalytics from '@danielgtmn/umami-react';

function App() {
  return (
    <>
      <UmamiAnalytics
        url="https://analytics.example.com"
        websiteId="your-website-id"
      />
      {/* Your app */}
    </>
  );
}

TypeScript

All types are exported:

import type {
  UmamiAnalyticsProps,
  UmamiConfig,
  PageviewData,
  UTMFetcher,
} from '@danielgtmn/umami-react';

Development

pnpm install          # Install dependencies
pnpm dev              # Watch mode
pnpm build            # Production build
pnpm test             # Run tests
pnpm test:coverage    # Tests with coverage
pnpm lint             # Lint
pnpm type-check       # Type check
pnpm size             # Check bundle size

Commits follow Conventional Commits. Git hooks (Husky) run type-check, lint, and tests before each commit.

Contributing

  1. Fork the repo
  2. Create your branch (git checkout -b feat/my-feature)
  3. Make sure all checks pass (pnpm test:run && pnpm lint && pnpm type-check)
  4. Commit using conventional commit format
  5. Open a Pull Request

License

MIT