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

@error-explorer/react

v1.2.0

Published

Error Explorer SDK for React - Automatic error tracking with React integration

Downloads

8

Readme

@error-explorer/react

Official Error Explorer SDK for React. Provides React-specific error handling with ErrorBoundary, hooks, and React Router integration.

Features

  • 🛡️ ErrorBoundary - Catch and report React component errors
  • 🪝 React Hooks - useErrorExplorer, useErrorHandler, useUserContext
  • 🔄 React Router integration - Automatic navigation breadcrumbs
  • 📦 HOC Support - withErrorBoundary for wrapping components
  • 🎯 Context Provider - Share SDK instance across your app
  • 📝 TypeScript - Full type definitions included

Installation

# npm
npm install @error-explorer/react

# yarn
yarn add @error-explorer/react

# pnpm
pnpm add @error-explorer/react

Quick Start

Option 1: Provider (Recommended)

import { ErrorExplorerProvider, ErrorBoundary } from '@error-explorer/react';

function App() {
  return (
    <ErrorExplorerProvider
      options={{
        token: 'ee_your_project_token',
        project: 'my-react-app',
        environment: 'production',
      }}
    >
      <ErrorBoundary>
        <MainContent />
      </ErrorBoundary>
    </ErrorExplorerProvider>
  );
}

Option 2: Direct Initialization

import { initErrorExplorer, ErrorBoundary } from '@error-explorer/react';

// In your entry file (main.tsx or index.tsx)
initErrorExplorer({
  token: 'ee_your_project_token',
  project: 'my-react-app',
  environment: 'production',
});

function App() {
  return (
    <ErrorBoundary>
      <MainContent />
    </ErrorBoundary>
  );
}

ErrorBoundary

Catch errors in component trees and report them to Error Explorer:

import { ErrorBoundary } from '@error-explorer/react';

// Basic usage
<ErrorBoundary>
  <RiskyComponent />
</ErrorBoundary>

// With custom fallback
<ErrorBoundary
  fallback={<div>Something went wrong</div>}
>
  <RiskyComponent />
</ErrorBoundary>

// With render prop fallback
<ErrorBoundary
  fallback={({ error, resetErrorBoundary }) => (
    <div>
      <p>Error: {error.message}</p>
      <button onClick={resetErrorBoundary}>Try again</button>
    </div>
  )}
>
  <RiskyComponent />
</ErrorBoundary>

// With callbacks and context
<ErrorBoundary
  onError={(error, errorInfo) => console.log('Caught:', error)}
  onReset={() => console.log('Reset')}
  tags={{ component: 'UserProfile' }}
  context={{ userId: '123' }}
>
  <UserProfile />
</ErrorBoundary>

ErrorBoundary Props

| Prop | Type | Description | |------|------|-------------| | children | ReactNode | Components to wrap | | fallback | ReactNode | Function | UI to show on error | | onError | Function | Called when error is caught | | onReset | Function | Called when boundary resets | | capture | boolean | Send to Error Explorer (default: true) | | tags | Record<string, string> | Additional tags for filtering | | context | Record<string, unknown> | Extra context data | | resetKeys | unknown[] | Keys that trigger reset when changed |

withErrorBoundary HOC

Wrap components with error boundary using HOC pattern:

import { withErrorBoundary } from '@error-explorer/react';

const SafeComponent = withErrorBoundary(RiskyComponent, {
  fallback: <ErrorFallback />,
  onError: (error) => console.error(error),
  tags: { feature: 'checkout' },
});

// Use it like a normal component
<SafeComponent userId="123" />

Hooks

useErrorExplorer

Access SDK methods from any component:

import { useErrorExplorer } from '@error-explorer/react';

function MyComponent() {
  const { captureException, addBreadcrumb, setUser } = useErrorExplorer();

  const handleClick = async () => {
    try {
      await riskyOperation();
    } catch (error) {
      captureException(error, {
        tags: { action: 'risky_operation' },
      });
    }
  };

  return <button onClick={handleClick}>Do Something</button>;
}

useErrorHandler

Simplified error handling for async operations:

import { useErrorHandler } from '@error-explorer/react';

function MyComponent() {
  const { handleError, wrapAsync, tryCatch } = useErrorHandler({
    tags: { component: 'MyComponent' },
  });

  // Option 1: Wrap async function
  const safeSubmit = wrapAsync(async (data) => {
    await api.submit(data);
  });

  // Option 2: Manual handling
  const handleClick = async () => {
    try {
      await riskyOperation();
    } catch (error) {
      handleError(error, { extra: { action: 'click' } });
    }
  };

  // Option 3: Sync try-catch wrapper
  const result = tryCatch(() => JSON.parse(data));

  return <button onClick={() => safeSubmit({ name: 'test' })}>Submit</button>;
}

useUserContext

Manage user context with automatic cleanup:

import { useUserContext } from '@error-explorer/react';

function App() {
  const currentUser = useAuth(); // Your auth hook

  // Automatically sets user context and clears on logout/unmount
  useUserContext(currentUser ? {
    id: currentUser.id,
    email: currentUser.email,
    name: currentUser.name,
    plan: currentUser.plan, // Custom fields allowed
  } : null);

  return <MainContent />;
}

useActionTracker

Track user interactions as breadcrumbs:

import { useActionTracker } from '@error-explorer/react';

function CheckoutForm() {
  const { trackAction, trackInteraction } = useActionTracker('CheckoutForm');

  const handleSubmit = () => {
    trackAction('checkout_submitted', { total: 149.99 });
    // ... submit logic
  };

  return (
    <form onSubmit={handleSubmit}>
      <input
        onFocus={() => trackInteraction('email-input', 'focus')}
        onBlur={() => trackInteraction('email-input', 'blur')}
      />
      <button onClick={() => trackInteraction('submit-button', 'click')}>
        Pay Now
      </button>
    </form>
  );
}

useComponentBreadcrumbs

Track component lifecycle:

import { useComponentBreadcrumbs } from '@error-explorer/react';

function UserDashboard() {
  // Adds breadcrumbs for mount/unmount
  useComponentBreadcrumbs('UserDashboard');

  return <div>Dashboard content</div>;
}

useErrorBoundary

Programmatically trigger error boundary from functional components:

import { ErrorBoundary, useErrorBoundary } from '@error-explorer/react';

function AsyncComponent() {
  const { showBoundary } = useErrorBoundary();

  const loadData = async () => {
    try {
      await fetchData();
    } catch (error) {
      showBoundary(error); // Triggers nearest ErrorBoundary
    }
  };

  return <button onClick={loadData}>Load Data</button>;
}

// Wrap with ErrorBoundary to catch the error
<ErrorBoundary>
  <AsyncComponent />
</ErrorBoundary>

React Router Integration

Track navigation as breadcrumbs:

Using the Hook (React Router v6+)

import { useLocation } from 'react-router-dom';
import { useRouterBreadcrumbs } from '@error-explorer/react/router';

function App() {
  const location = useLocation();

  // Track navigation automatically
  useRouterBreadcrumbs(location, {
    trackQuery: false,  // Don't include query params (default)
    trackHash: false,   // Don't include hash (default)
  });

  return <Routes>{/* your routes */}</Routes>;
}

Using the Router Subscriber

import { createBrowserRouter } from 'react-router-dom';
import { createNavigationListener } from '@error-explorer/react/router';

const router = createBrowserRouter([/* routes */]);

// Subscribe to navigation
createNavigationListener(router);

// In your app
<RouterProvider router={router} />

Using HOC

import { BrowserRouter } from 'react-router-dom';
import { withRouterTracking } from '@error-explorer/react/router';

const TrackedRouter = withRouterTracking(BrowserRouter, {
  trackQuery: true,
});

function App() {
  return (
    <TrackedRouter>
      <Routes>{/* your routes */}</Routes>
    </TrackedRouter>
  );
}

TypeScript Support

Full TypeScript support with exported types:

import {
  ErrorBoundary,
  ErrorExplorerProvider,
  useErrorExplorer,
  type ReactErrorExplorerOptions,
  type ErrorBoundaryProps,
  type FallbackProps,
  type ErrorExplorerContextValue,
} from '@error-explorer/react';

// All types are fully typed
const options: ReactErrorExplorerOptions = {
  token: 'ee_token',
  project: 'my-app',
  environment: 'production',
};

Configuration

All configuration options from @error-explorer/browser are supported, plus React-specific options:

<ErrorExplorerProvider
  options={{
    // Required
    token: 'ee_your_project_token',
    project: 'my-react-app',

    // Recommended
    environment: 'production',
    release: '1.0.0',

    // React-specific
    captureComponentStack: true, // Include React component stack (default: true)

    // Filtering
    ignoreErrors: [/ResizeObserver/],

    // Hooks
    beforeSend: (event) => {
      // Modify or filter events
      return event;
    },
  }}
>
  <App />
</ErrorExplorerProvider>

Best Practices

  1. Wrap at the top level - Add ErrorBoundary at your app's root
  2. Use multiple boundaries - Add ErrorBoundaries around critical sections
  3. Set user context early - Use useUserContext after authentication
  4. Track key actions - Use useActionTracker for important user flows
  5. Use meaningful tags - Add tags like feature, component, action

Example: Complete Setup

// main.tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import {
  ErrorExplorerProvider,
  ErrorBoundary,
} from '@error-explorer/react';
import App from './App';

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <ErrorExplorerProvider
      options={{
        token: import.meta.env.VITE_ERROR_EXPLORER_TOKEN,
        project: 'my-react-app',
        environment: import.meta.env.MODE,
        release: import.meta.env.VITE_APP_VERSION,
      }}
    >
      <ErrorBoundary
        fallback={({ error, resetErrorBoundary }) => (
          <div className="error-page">
            <h1>Oops! Something went wrong</h1>
            <p>{error.message}</p>
            <button onClick={resetErrorBoundary}>Try again</button>
          </div>
        )}
      >
        <BrowserRouter>
          <App />
        </BrowserRouter>
      </ErrorBoundary>
    </ErrorExplorerProvider>
  </React.StrictMode>
);

Related Packages

  • @error-explorer/browser - Core browser SDK
  • @error-explorer/vue - Vue.js SDK
  • @error-explorer/node - Node.js SDK

License

MIT