Error Boundary
boldkit/error-boundaryFreeComponent
Error boundary wrapper with neubrutalism-styled fallback UI. Used by math-curve components to catch runtime errors gracefully.
Live preview
live · rendered by the registry
Rendered by boldkit on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://boldkit.dev/r/error-boundary.jsonSource
1import { Component, type ReactNode } from 'react'2import { Button } from '@/components/ui/button'3import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'4import { AlertTriangle, RefreshCw, Home } from 'lucide-react'56interface Props {7 children: ReactNode8}910interface State {11 hasError: boolean12 error?: Error13}1415export class ErrorBoundary extends Component<Props, State> {16 constructor(props: Props) {17 super(props)18 this.state = { hasError: false }19 }2021 static getDerivedStateFromError(error: Error): State {22 return { hasError: true, error }23 }2425 componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {26 // Log error to console in development27 if (process.env.NODE_ENV === 'development') {28 console.error('Error caught by boundary:', error, errorInfo)29 }30 }3132 handleReload = () => {33 window.location.reload()34 }3536 handleGoHome = () => {37 window.location.href = '/'38 }3940 render() {41 if (this.state.hasError) {42 return (43 <div className="min-h-screen bg-background flex items-center justify-center p-4">44 <Card className="max-w-lg w-full">45 <CardHeader className="bg-destructive">46 <CardTitle className="flex items-center gap-3">47 <AlertTriangle className="h-6 w-6 stroke-[3]" />48 Something went wrong49 </CardTitle>50 </CardHeader>51 <CardContent className="pt-6 space-y-4">52 <p className="text-muted-foreground">53 An unexpected error occurred. This has been logged and we'll look into it.54 </p>55 {process.env.NODE_ENV === 'development' && this.state.error && (56 <pre className="bg-muted border-3 border-foreground p-4 text-sm overflow-x-auto">57 <code>{this.state.error.message}</code>58 </pre>59 )}60 <div className="flex gap-3">61 <Button onClick={this.handleReload} className="gap-2">62 <RefreshCw className="h-4 w-4" />63 Reload Page64 </Button>65 <Button variant="outline" onClick={this.handleGoHome} className="gap-2">66 <Home className="h-4 w-4" />67 Go Home68 </Button>69 </div>70 </CardContent>71 </Card>72 </div>73 )74 }7576 return this.props.children77 }78}
What it pulls in
Other registry items
Files it writes
More from boldkit
All 94 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | boldkit | Components | Free | 2 deps | |
| Alertalert | boldkit | Components | Free | 2 deps | |
| Alert Dialogalert-dialog | boldkit | Components | Free | 1 dep | |
| ASCII Shapesascii-shapes | boldkit | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | boldkit | Components | Free | 1 dep | |
| Avataravatar | boldkit | Components | Free | 1 dep | |
| Badgebadge | boldkit | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | boldkit | Components | Free | 2 deps |
