An error file defines an error boundary for a route segment.

Error boundaries must be Client Components.

'use client';

// 'use client' marks this page as a Client Component

import { useEffect } from 'react';

export default function Error({ error, reset }: {
  error: Error;
  reset: () => void;
}) {
  useEffect(() => {
    // Log the error to an error reporting service
  }, [error]);

  return (
      <p>Something went wrong!</p>
      <button onClick={() => reset()}>Reset error boundary</button>
  • error: An instance of an Error object. This error can happen on the server or the client.
  • reset(): A function to reset the error boundary, which does not return a response.

Next Steps