UNPKG

@critters/next

Version:

Secure bug reporting library for Next.js applications

41 lines (40 loc) 1.65 kB
import { NextApiHandler } from "./types"; import React from "react"; /** * Create a middleware for Next.js API routes to catch and report errors * @param handler The Next.js API route handler * @param options Additional options for error reporting * @returns A wrapped handler that reports errors */ export declare function withErrorReporting(handler: NextApiHandler, options?: { captureRequest?: boolean; captureResponse?: boolean; onError?: (error: Error, req: any, res: any) => void; }): NextApiHandler; /** * Create a middleware for Next.js pages to catch and report errors * @param options Additional options for error reporting * @returns A higher-order component that wraps the page component */ export declare function withPageErrorReporting(options?: { captureProps?: boolean; captureInitialProps?: boolean; onError?: (error: Error, ctx: any) => void; }): (PageComponent: React.ComponentType<any>) => { (props: any): React.ReactElement<any, string | React.JSXElementConstructor<any>>; displayName: string; getInitialProps(ctx: any): Promise<any>; }; /** * Create a middleware for Next.js App Router to catch and report errors * @param options Additional options for error reporting * @returns A higher-order component that wraps the page component */ export declare function withAppErrorReporting(options?: { captureParams?: boolean; captureSearchParams?: boolean; onError?: (error: Error, props: any) => void; }): (AppComponent: React.ComponentType<any>) => { (props: any): React.ReactElement<any, string | React.JSXElementConstructor<any>>; displayName: string; };