TheDocumentation Index
Fetch the complete documentation index at: https://docs.mcp-use.com/llms.txt
Use this file to discover all available pages before exploring further.
ErrorBoundary component catches React errors anywhere in the child component tree, logs those errors, and displays a fallback UI instead of crashing the entire widget.
Import
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | required | The widget content to wrap |
fallback | ReactNode | (error: Error) => ReactNode | Built-in error card | Custom UI to render when an error is caught |
onError | (error: Error, errorInfo: React.ErrorInfo) => void | — | Callback invoked when an error is caught |
Basic Usage
Custom Fallback
Pass afallback prop to render your own error UI instead of the default red error card.
Static Fallback
Dynamic Fallback with Error Details
Pass a function to receive the error object:Error Callback
UseonError to log errors to an analytics service or perform side effects:
fallback and onError:
Automatic Inclusion
ErrorBoundary is automatically included when using McpUseProvider:
Default Error Display
When nofallback is provided and an error occurs, the boundary displays:
- A red-bordered error container
- The error message in a readable format
- Dark mode support (adapts to theme)
Error Logging
Errors are always logged to the console with:- The error object
- React error info (component stack, etc.)
onError is provided.
Related Components
McpUseProvider- Includes ErrorBoundary automaticallyuseWidget- Widget hook for accessing props and actions