Question presented to candidate: "Name the special files you can put in an App Router segment and tell me what each one does. In what order do they wrap the page?"
What a strong answer should cover:
pagerenders the route and makes it public;layoutwraps it and persists across navigation;templatewraps it but remounts on every navigation.loadingbecomes a Suspense fallback around the page, so the server can stream it immediately.errormust be a Client Component and becomes an error boundary; itsretryprop (stable since 16.3) re-fetches and re-renders the segment,resetonly clears the error. Production sends only an error digest, not the message.not-foundrenders whennotFound()is called;global-error,route,defaultand metadata files complete the set.- The nesting order: layout, then template, then error, then loading, then not-found, then the page.
Clarifying questions expected:
- "Should the error screen replace the navigation too?" β an error file does not catch errors in the layout of the same segment.
- "Do you need a real 404 status code?" β it depends on whether anything streamed before notFound() ran.
Code / implementation expected: Yes β a segment with each file, and what each renders.