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

react-monitoring

v1.0.37

Published

A flexible, plug-and-play monitoring and logging library for React applications with native support for Sentry, Datadog, and custom providers.

Readme

🧩 React Monitoring & Logger

A flexible, plug-and-play monitoring and logging library for React applications.

Easily track logs and runtime errors with native support for Datadog, Sentry and LogRocket and custom providers.

Need a specific provider or functionality? Open an issue.

Perfect for React developers who want robust error tracking and logging out of the box.


📦 Installation

npm install react-monitoring

🚀 Quickstart

import { monitor, logger, ErrorBoundary, withErrorBoundary } from 'react-monitoring';

monitor.init({
  provider: 'datadog',
  token: 'YOUR_CLIENT_TOKEN',
  environment: 'production',
  service: 'my-frontend-service',
});

logger.info({
  message: 'User logged in successfully',
});

🔧 API

monitor.init(config: MonitorInitConfig)

Initializes the monitoring system.

| Property | Type | Description | Required | Default | |---------------------------|-----------------------------------|-----------------------------------------------------|----------------------------------|--------------------------------| | provider | "datadog" "sentry" "logrocket" "custom" | Monitoring provider | ✅ Yes | — | | token | string | Provider API token | ✅ Yes | — | | environment | string | Environment name (e.g., production, staging) | 🔶 Recommended | "production" | | service | string | Logical name of the service | 🔶 Recommended | "frontend" | | site | string | Provider site domain (Datadog only) | 🔶 Recommended (Datadog only) | Based on provider | | trackErrors | boolean | Automatically forward runtime errors | ❌ Optional | false | | customLoggerFn | (entry: LogEntry) => void | Required if using custom provider | ✅ Yes (for custom) | — | | errorBoundaryDefaultValues | { fallback?: React.ReactNode, logOptions?: Partial<LogEntry> & { message?: string } } | Default fallback UI and log settings for errors | ❌ Optional | <div>Something went wrong.</div>, { level: "error", message: "An error occurred in the application", logProperties: {}, } |


logger.info / logger.warn / logger.error

Unified interface for sending logs.

interface LogEntry {
  message: string;
  logProperties?: Record<string, any>;
}

Example:

logger.error({
  message: 'Form submission error',
  logProperties: { field: 'email' },
});

🧱 Error Components

ErrorBoundary

New to Error Boundaries? Read the official React docs

Wraps part of your app to automatically catch and log render-time errors.

<ErrorBoundary
  fallback={<div>Oops, something went wrong!</div>}
  logOptions={{
    level: 'error',
    message: 'Error on the homepage',
  }}
>
  <App />
</ErrorBoundary>
  • fallback: React node to render when an error is caught.
  • logOptions: Optional log config. Defaults come from monitor.init().

withErrorBoundary HOC

Wrap components with automatic error catching + logging.

export default withErrorBoundary(MyComponent, {
  level: 'error',
  message: 'Profile loading failed',
});

Also uses global fallback and log options if not specified.


✨ Features

  • Easy setup with full TypeScript support and autocomplete.
  • Global fallback UI and error log options.
  • Native integrations with Datadog.
  • Support for custom logging providers.
  • React-friendly error capturing with ErrorBoundary and withErrorBoundary.
  • Logging levels: info, warn, and error.

🧪 Testing

Easily mock your custom logger for unit tests:

monitor.init({
  provider: 'custom',
  customLoggerFn: jest.fn(),
});

Need an example? Here


📄 License

MIT


🔍 Keywords

React, monitoring, logging, error tracking, frontend observability, Sentry, Datadog, LogRocket, error boundary, React hooks, TypeScript