ErrorBoundary

a React boundary component that renders a fallback UI when an error occurs.

You can customize the fallback UI by passing a fallback prop to the ErrorBoundary component.

Open in
I will throw an error in 2 seconds,the error will be caught by the ErrorBoundary

Installation

pnpm dlx shadcn@latest add https://mhl5.vercel.app/r/ErrorBoundary.json

Usage

import ErrorBoundary from "@/components/ui/ErrorBoundary";

<ErrorBoundary>
  <Component />
</ErrorBoundary>