* );
* }
* ```
*/
export interface ErrorBoundaryFallbackProps {
/** Error information */
error: ErrorInfo;
}
/**
* Error boundary handler - receives error info and returns fallback UI
*/
export type ErrorBoundaryHandler = (
props: ErrorBoundaryFallbackProps,
) => ReactNode;
/**
* Props passed to client-side error boundary fallback components
*
* Client error boundaries have a reset function that clears the error state
* and re-renders the children.
*
* @example
* ```typescript
* function ClientErrorFallback({ error, reset }: ClientErrorBoundaryFallbackProps) {
* return (
*
*
Something went wrong
*
{error.message}
*
*
* );
* }
* ```
*/
export interface ClientErrorBoundaryFallbackProps {
/** Error information */
error: ErrorInfo;
/** Function to reset error state and retry rendering */
reset: () => void;
}
/**
* Wrapped loader data result for deferred resolution with error handling.
* When loaders are deferred to client-side resolution, errors need to be
* wrapped so the client can handle them appropriately.
*/
export type LoaderDataResult =
| { __loaderResult: true; ok: true; data: T }
| {
__loaderResult: true;
ok: false;
error: ErrorInfo;
fallback: ReactNode | null;
};
/**
* Type guard to check if a value is a wrapped loader result
*/
export function isLoaderDataResult(value: unknown): value is LoaderDataResult {
return (
typeof value === "object" &&
value !== null &&
"__loaderResult" in value &&
(value as any).__loaderResult === true
);
}
/**
* Not found information passed to notFound boundary fallback components
*/
export interface NotFoundInfo {
/** Not found message */
message: string;
/** Segment ID where notFound was thrown */
segmentId: string;
/** Segment type where notFound was thrown */
segmentType:
| "layout"
| "route"
| "parallel"
| "loader"
| "middleware"
| "cache";
/** The pathname that triggered the not found */
pathname?: string;
}
/**
* Props passed to notFound boundary fallback components
*
* @example
* ```typescript
* function ProductNotFound({ notFound }: NotFoundBoundaryFallbackProps) {
* return (
*