Browser monitoring is a beta AppSignal Labs feature. The
@appsignal/browser package is published under the beta tag on npm, and its
configuration and API may still change between beta releases. Share feedback
in our Discord community.window, they unmount the tree. An error boundary is the only way to see them. AppSignal for Browser ships one as a subpath export of the package, so there is nothing extra to install.
Optional: React 16.8 or later, if you want to use the error boundary shipped with the package.
Catching render errors
captureError is passed as a prop rather than imported by the boundary itself, so the same component works for both the ES module and the UMD build.
Errors caught this way arrive with the name of the component that threw, and the full list of components it was nested inside at the time. That is usually enough to find the problem without reproducing it.
Recovering from an error
Pass a function asfallback to give the user a way to try again. It receives the error and a reset function, which clears the error and renders the children again:
Wrapping a single component
withErrorBoundary wraps one component, which is convenient for widgets that should fail without taking the page down:
Props
Place boundaries where a failure has a sensible fallback: around each route, and around individual widgets that can be missing without breaking the page. One boundary at the root catches everything, but replaces your whole application with the fallback.
Reporting the current route
Report the current route on every navigation, using the template such as/orders/:id rather than the resolved path.
Import your AppSignal setup before your router. The SDK and most routers both
patch
history.pushState, and the SDK composes with an existing patch rather
than replacing it. Loading the router first can leave client-side navigation
unreported.Reporting errors from event handlers and effects
An error boundary catches errors thrown during rendering. It does not catch errors thrown in an event handler, asetTimeout, or a rejected promise inside an effect. Uncaught ones reach window and are reported automatically. For the rest, report them yourself: