Next.js · Middle · Question 23 of 75
How does global-error.tsx differ from error.tsx?
- ✓Correct answer: It catches root layout errors and renders its own
<html>and<body> - 2It catches errors only during the
next buildcommand - 3It's the same as
error.tsx, but forroute.tsAPI routes
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.