CodeZettaInterview Hub

Next.js · App Router · Mid-Level · Concept

Explain loading.tsx and error.tsx in a route segment.

Short Interview Answer

`loading.tsx` shows an instant loading UI via Suspense; `error.tsx` is an error boundary for that segment.

Detailed Explanation

Next wraps the segment in Suspense so navigations can show fallbacks. `error.tsx` must be a Client Component and can reset. Errors bubble to the nearest error boundary. Use them to keep shells interactive while content streams.

Did you know this answer?