An overlay for displaying stack frames and error messages in React development environments.
npx @tessl/cli install tessl/npm-react-error-overlay@6.1.0React Error Overlay is a development-only error reporting system for React applications. It displays formatted runtime errors and compilation errors in an iframe-based overlay with syntax highlighting, source code context, and clickable stack frames that can open files in editors. The library provides error deduplication, automatic error listening, and seamless integration with Create React App's development workflow.
npm install react-error-overlayimport {
startReportingRuntimeErrors,
stopReportingRuntimeErrors,
reportBuildError,
reportRuntimeError,
dismissBuildError,
dismissRuntimeErrors,
setEditorHandler
} from "react-error-overlay";For CommonJS:
const {
startReportingRuntimeErrors,
stopReportingRuntimeErrors,
reportBuildError,
reportRuntimeError,
dismissBuildError,
dismissRuntimeErrors,
setEditorHandler
} = require("react-error-overlay");import {
startReportingRuntimeErrors,
stopReportingRuntimeErrors,
setEditorHandler
} from "react-error-overlay";
// Start automatic error reporting in development mode
if (process.env.NODE_ENV === 'development') {
startReportingRuntimeErrors({
onError: () => {
console.log('Error detected and displayed in overlay');
}
});
// Set up editor integration (optional)
setEditorHandler((errorLocation) => {
// Open file in editor at specific location
fetch('/__open-stack-frame-in-editor', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(errorLocation)
});
});
}
// Later: stop error reporting when switching modes
// stopReportingRuntimeErrors();React Error Overlay consists of several key components:
Core error reporting functionality for both automatic monitoring and manual error reporting. Handles runtime errors, build errors, and provides error deduplication.
function startReportingRuntimeErrors(options: RuntimeReportingOptions): void;
function stopReportingRuntimeErrors(): void;
function reportRuntimeError(error: Error, options?: RuntimeReportingOptions): void;
function reportBuildError(error: string): void;
interface RuntimeReportingOptions {
onError: () => void;
filename?: string;
/** @deprecated launchEditorEndpoint is no longer supported. Use setEditorHandler instead. */
launchEditorEndpoint?: string;
}Functions for clearing and dismissing errors from the overlay interface.
function dismissRuntimeErrors(): void;
function dismissBuildError(): void;Integration with code editors to enable opening files at specific locations when stack frames are clicked.
function setEditorHandler(handler: EditorHandler | null): void;
type EditorHandler = (errorLoc: ErrorLocation) => void;
interface ErrorLocation {
fileName: string;
lineNumber: number;
colNumber?: number;
}interface RuntimeReportingOptions {
onError: () => void;
filename?: string;
/** @deprecated launchEditorEndpoint is no longer supported. Use setEditorHandler instead. */
launchEditorEndpoint?: string;
}
type EditorHandler = (errorLoc: ErrorLocation) => void;
interface ErrorLocation {
fileName: string;
lineNumber: number;
colNumber?: number;
}