Next.js · Middle · Question 23 of 75

How does global-error.tsx differ from error.tsx?

Explanation

An error.tsx at the root won't catch an error in the root layout itself - it lives inside it. global-error.tsx replaces the whole document, so it includes its own styles and markup. You can't export metadata from it; use React's <title> instead.

Further reading

Problem with a question

Next.js · Middle · question 23

Test yourself

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

Take this quiz