New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bugsnag-react

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bugsnag-react

React integration for bugsnag-js

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

Bugsnag: React

Documentation Build status NPM

NPM

A bugsnag-js plugin for React. Learn more about error reporting for React applications with Bugsnag.

This package enables you to integrate Bugsnag's error reporting with React's error boundaries. It creates and configures an <ErrorBoundary/> component which will capture and report unhandled errors in your component tree. You either use the <ErrorBoundary/> directly, or extend it to provide some fallback UI for your users.

Reported errors will contain useful debugging info from Reacts's internals such as the component name where the error originated, and the component stack.

Installation

You can opt to install the package from npm, using the instructions below. Alternatively you can load the plugin from our CDN via a <script/> tag.

CDN

<script src="//d2wy8f7a9ursnm.cloudfront.net/v4/bugsnag.min.js"></script>
<script src="//d2wy8f7a9ursnm.cloudfront.net/bugsnag-plugins/v1/bugsnag-react.min.js"></script>

npm

npm i --save bugsnag-js bugsnag-react
# or
yarn add bugsnag-js bugsnag-react

Usage

Depending on how your application is structured, usage differs slightly:

Inline script tag

The script tag creates a global function called bugsnag__react which needs to be passed a reference to the React object. Ensure that React is defined before calling this function.

<script>
  window.bugsnagClient = bugsnag('API_KEY')
</script>
<script>
  // in your react app…
  var ErrorBoundary = bugsnagClient.use(bugsnag__react(React))
  ReactDOM.render(
    <ErrorBoundary>
      <YourApp />
    </ErrorBoundary>,
    document.getElementById('app')
  )
</script>

See the example for more info.

Bundled

// initialize bugsnag ASAP, before other imports
import bugsnag from 'bugsnag-js'
const bugsnagClient = bugsnag('API_KEY')

import ReactDOM from 'react-dom'
import React from 'react'
import createPlugin from 'bugsnag-react'

// wrap your entire app tree in the ErrorBoundary provided
const ErrorBoundary = bugsnagClient.use(createPlugin(React))
ReactDOM.render(
  <ErrorBoundary>
    <YourApp />
  </ErrorBoundary>,
  document.getElementById('app')
)

Support

License

The Bugsnag JS library and official plugins are free software released under the MIT License. See LICENSE.txt for details.

FAQs

Package last updated on 06 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc