Flare by Spatie
    • Error Tracking
    • Performance Monitoring
    • Logs
  • Pricing
  • Docs
  • Insights
  • Changelog
  • Back to Flare ⌘↵ Shortcut: Command or Control Enter
  • Sign in
  • Try Flare for free
  • Error Tracking
  • Performance Monitoring
  • Logs
  • Pricing
  • Docs
  • Insights
  • Changelog
    • Back to Flare ⌘↵ Shortcut: Command or Control Enter
    • Try Flare for free
    • Sign in
Flare Flare Laravel Laravel PHP PHP JavaScript JavaScript React React Vue Vue Svelte Svelte Protocol Protocol
  • General
  • Installation
  • Resolving bundled code
  • API reference
  • Electron
  • Configuration
  • Errors
  • Error boundary
  • Error handler
  • Reporting errors
  • Client hooks
  • Data Collection
  • Adding custom context
  • Adding glows
  • Identifying users

Installation

Flare's React integration uses two packages:

  • @flareapp/js - the core Flare client that catches errors and sends them to Flare,
  • @flareapp/react - the React integration that provides an error boundary and error handler.

React 16, 17, 18, and 19 are supported.

Optionally, you can also use the sourcemap plugin (Vite/Webpack) for resolving bundled code.

Looking for the docs for V1 of the JavaScript SDK? Find them here.

The interactive guide above installs the packages, initializes the Flare client, connects your project key, and verifies your setup. The sections below cover the React-specific error handling you can add on top.

Wrapping your app in the error boundary

Next, wrap your component tree with the FlareErrorBoundary to catch React rendering errors:

import { flare } from '@flareapp/js';
import { FlareErrorBoundary } from '@flareapp/react';

// Initialize Flare with the production guard from the guide above
flare.light('YOUR PROJECT KEY');

function App() {
    return (
        <FlareErrorBoundary>
            <Root />
        </FlareErrorBoundary>
    );
}

This will catch any errors that occur during rendering and report them to Flare with React-specific context like the component stack trace.

You can learn more about the error boundary and its options in the Error boundary docs.

Using the React error handler (React 19+)

React 19 introduced a new way of handling errors through createRoot and hydrateRoot callbacks. If you're on React 16–18, the error boundary alone handles rendering errors — you can skip this section.

You can use flareReactErrorHandler to integrate Flare with these callbacks:

import { flareReactErrorHandler } from '@flareapp/react';
import { createRoot } from 'react-dom/client';

const root = createRoot(document.getElementById('root'), {
    onCaughtError: flareReactErrorHandler(),
    onUncaughtError: flareReactErrorHandler(),
    onRecoverableError: flareReactErrorHandler(),
});

You can learn more about the error handler in the Error handler docs.

Reporting errors, hooks and context

The React integration builds on top of the core JavaScript client. For features shared with the JavaScript client, see the JavaScript docs:

  • Reporting errors
  • Client hooks
  • Adding custom context
  • Adding glows

Important notes

  • If flare.light() hasn't been called (e.g. in development when using the production guard), errors are silently ignored — no reports are queued. See the JavaScript installation docs for details.
  • In React development mode, you will see that many errors are reported twice. This is expected behaviour caused by React's StrictMode and will not occur in a production bundle (read more).
  • Errors in a development environment might not always be reported. To verify the Flare client is set up correctly, test with a production build.
Identifying users Resolving bundled code
  • On this page
  • Wrapping your app in the error boundary
  • Using the React error handler (React 19+)
  • Reporting errors, hooks and context
  • Important notes

Catch errors and fix slowdowns with Flare, the full-stack application monitoring platform for Laravel, PHP & JavaScript.

  • Platform
  • Error Tracking
  • Performance Monitoring
  • Pricing
  • Support
  • Resources
  • Insights
  • Newsletter
  • Changelog
  • Documentation
  • Affiliate program
  • uptime status badge Service status
  • Terms of use
  • DPA
  • Privacy & cookie Policy
Made in by
Flare