Next.js · Junior · Question 12 of 75

Why must error.tsx be a client component?

Explanation

error.tsx wraps the segment in an error boundary - a client-side mechanism. The component receives error and a retry() function that reloads and re-renders the segment (there's also reset() - re-render without refetching data). Errors in the root layout are caught by global-error.tsx.

Further reading

Problem with a question

Next.js · Junior · question 12

Test yourself

Take the Next.js · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz