Error Boundary
NewCatches render errors and shows a retry panel with details instead of a blank page. Resets on retry or resetKeys.
Revenue this month
$48,290
Errors sent to logging: 0
Installation
$ pnpm dlx shadcn@latest add @synccn/error-boundaryFirst time in this project? Connect synccn with one command.
Usage
import { ErrorBoundary, ErrorFallback } from "@/components/ui/error-boundary";<ErrorBoundary onError={report} resetKeys={[id]}><Widget /></ErrorBoundary>API reference
Generated from the component's TypeScript types, so it always matches the code.
ErrorFallback
The default "Something went wrong" panel: message, retry and the stack trace behind a toggle.
PropTypeDescription
- errorrequired
Error—
- resetrequired
() => voidClears the error and renders the children again.
- title
React.ReactNodeDefault
"Something went wrong"Heading.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
- lib/utilscn (merges class names)
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for AlertOctagon, ChevronDown, RotateCcw
Accessibility
- The fallback is an alert, so it's announced when it replaces the content.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: alert
- ARIA attributes: aria-expanded
- Announces changes to screen readers
More feedback
AlertInline message in five tones, with action and dismiss.ToastStacked notifications with actions, promises and hover to expand.ProgressLinear progress, determinate or indeterminate.Progress RingCircular progress with content in the middle.SkeletonShimmering placeholder while content loads.SpinnerEight-bar loading indicator.