'use client'
import * as React from 'react'
import { cn } from '../../lib/utils'
export interface RouteError extends Error {
digest?: string
}
export interface RouteErrorBoundaryProps {
/** The error thrown during render — matches the Next.js `error.tsx` contract. */
error: RouteError
/** Re-render the route segment — matches the Next.js `error.tsx` contract. */
reset: () => void
/** Heading shown above the message. */
title?: string
/** Body copy shown in production (the raw error is only shown in development). */
description?: string
/** Label for the primary (retry) action. */
retryLabel?: string
/** Label for the secondary (home) action. Hidden when `homeHref` is null. */
homeLabel?: string
/** Destination for the secondary action. Pass `null` to hide it. Defaults to `/`. */
homeHref?: string | null
/**
* Render-prop override for the entire surface. Receives the error plus the
* resolved `reset`/`goHome` handlers so apps can fully brand the page while
* keeping the Next.js wiring.
*/
children?: (props: {
error: RouteError
reset: () => void
goHome: () => void
}) => React.ReactNode
/** Called once on mount with the error — wire up your logger/Sentry here. */
onError?: (error: RouteError) => void
/** Override the outer wrapper className. */
className?: string
}
/**
* Route-level error surface for an app's `app/error.tsx`.
*
* Implements the Next.js App Router error contract (`{ error, reset }`) and
* renders a neutral, brandable error card. Stack/digest details are only shown
* in development. Use render-prop `children` for full custom UI.
*
* @example
* // app/error.tsx
* 'use client'
* import { RouteErrorBoundary } from '@startsimpli/ui'
* export default function Error(props: { error: Error & { digest?: string }; reset: () => void }) {
* return
{description}
{isDevelopment && (Error (development only)
{error.message}
{error.digest && (Digest: {error.digest}
)} {error.stack && (
{error.stack}
Reference:{' '}
{error.digest}