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

@bugshot/react

v1.0.0

Published

BugShot React integration

Readme

@bugshot/react

Official BugShot integration for React applications.

npm version License: MIT

🚀 Features

  • Error Boundary - Catch React component errors
  • Provider Component - Easy setup
  • React Hooks - Functional components support
  • TypeScript Support - Full type definitions
  • Automatic Error Capture - Works out of the box
  • Custom Fallback UI - Show friendly error messages

📦 Installation

npm install @bugshot/react @bugshot/browser-sdk

🔧 Quick Start

1. Basic Setup with Provider

import { BugShotProvider, ErrorBoundary } from '@bugshot/react';

function App() {
  return (
    <BugShotProvider config={{ apiKey: 'your-api-key' }}>
      <ErrorBoundary>
        <YourApp />
      </ErrorBoundary>
    </BugShotProvider>
  );
}

2. Error Boundary Only

import { ErrorBoundary } from '@bugshot/react';
import BugShot from '@bugshot/browser-sdk';

// Initialize SDK first
BugShot.init({ apiKey: 'your-api-key' });

function App() {
  return (
    <ErrorBoundary fallback={<div>Oops! Something went wrong.</div>}>
      <YourApp />
    </ErrorBoundary>
  );
}

📖 Usage Examples

Custom Fallback UI

<ErrorBoundary
  fallback={(error, errorInfo) => (
    <div>
      <h1>Error Occurred</h1>
      <p>{error.message}</p>
      <button onClick={() => window.location.reload()}>
        Reload Page
      </button>
    </div>
  )}
>
  <YourApp />
</ErrorBoundary>

With Error Callback

<ErrorBoundary
  onError={(error, errorInfo) => {
    console.log('Error caught:', error);
    analytics.track('error_occurred', {
      error: error.message,
      componentStack: errorInfo.componentStack
    });
  }}
>
  <YourApp />
</ErrorBoundary>

Using Hooks

import { useBugShot } from '@bugshot/react';

function MyComponent() {
  const { captureError, captureMessage, setUser } = useBugShot();

  const handleClick = async () => {
    try {
      await fetchData();
    } catch (error) {
      captureError(error);
    }
  };

  useEffect(() => {
    setUser({
      id: '123',
      email: '[email protected]'
    });

    captureMessage('Component mounted', 'info');
  }, []);

  return <button onClick={handleClick}>Click me</button>;
}

Next.js App Router

// app/providers.tsx
'use client';

import { BugShotProvider, ErrorBoundary } from '@bugshot/react';

export function Providers({ children }) {
  return (
    <BugShotProvider
      config={{
        apiKey: process.env.NEXT_PUBLIC_BUGSHOT_API_KEY!,
        environment: process.env.NODE_ENV
      }}
    >
      <ErrorBoundary>
        {children}
      </ErrorBoundary>
    </BugShotProvider>
  );
}
// app/layout.tsx
import { Providers } from './providers';

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        <Providers>{children}</Providers>
      </body>
    </html>
  );
}

Next.js Pages Router

// pages/_app.tsx
import { BugShotProvider, ErrorBoundary } from '@bugshot/react';

function MyApp({ Component, pageProps }) {
  return (
    <BugShotProvider
      config={{
        apiKey: process.env.NEXT_PUBLIC_BUGSHOT_API_KEY!,
        environment: process.env.NODE_ENV,
        release: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA
      }}
    >
      <ErrorBoundary>
        <Component {...pageProps} />
      </ErrorBoundary>
    </BugShotProvider>
  );
}

export default MyApp;

🎯 API Reference

<BugShotProvider>

Provider component to initialize BugShot SDK.

Props:

  • config (BugShotConfig): SDK configuration
  • children (ReactNode): Child components
<BugShotProvider config={{ apiKey: 'your-key' }}>
  <App />
</BugShotProvider>

<ErrorBoundary>

React Error Boundary component.

Props:

  • children (ReactNode): Components to monitor
  • fallback (ReactNode | Function): Fallback UI to show on error
  • onError (Function): Callback when error occurs
  • reportToBugShot (boolean): Send errors to BugShot (default: true)
<ErrorBoundary
  fallback={<ErrorFallback />}
  onError={(error, errorInfo) => {
    console.log('Error:', error);
  }}
>
  <App />
</ErrorBoundary>

useBugShot()

React Hook for error tracking in functional components.

Returns:

  • captureError(error, additionalInfo?): Capture an error
  • captureMessage(message, level?): Capture a message
  • setUser(user): Set user info
  • setContext(key, value): Add context
const { captureError, captureMessage, setUser, setContext } = useBugShot();

🛠️ TypeScript

Full TypeScript support included:

import type { BugShotConfig } from '@bugshot/react';

const config: BugShotConfig = {
  apiKey: 'your-api-key',
  environment: 'production',
  release: '1.0.0'
};

📝 License

MIT © BugShot Team

🔗 Links