App Router foundations · senior
Parallel and intercepting routes (the modal pattern)
Parallel routes (@slot folders) render several pages in one layout; combined with intercepting routes ((.)photo/[id]) they give modals with a real, shareable URL that open on soft navigation and show the full page on refresh.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- A slot
@modalis passed to the parent layout as a prop ({ children, modal }). Slots are not URL segments. - Soft navigation keeps each slot's active page even if it does not match the URL; a hard navigation (refresh) cannot recover it and renders
default.tsxfor unmatched slots, or a 404 if there is none. - Next.js 16 requires an explicit
default.jsfor every parallel slot (the build fails without it); returnnullor callnotFound(). - Intercepting conventions:
(.)same level,(..)one level up,(..)(..)two levels up,(...)from the app root. - Modal recipe:
app/@modal/default.tsxreturnsnull;app/@modal/(.)photo/[id]/page.tsxrenders<Modal><Photo/></Modal>;app/photo/[id]/page.tsxis the full page for direct visits. - Close with
router.back(); when navigating away with<Link>, match the slot to a page or catch-all that returnsnull. - Security: conditional slots (admin vs user) both render on the server; authorise inside each slot's page or the DAL.
- Slots can have their own
loadinganderrorfiles and stream independently.
The red pen
Common traps: mistake → fix
Mistake: "Keep modal open state in client context"
Fix: no shareable URL, Back does not close it.
Mistake: "Returning the admin slot only for admins protects it"
Fix: both slots run and are sent; authorise in the slot.
Mistake: "default.js is optional"
Fix: required for every slot in Next 16.
Easy to hard
Questions interviewers ask, easy to hard
- Build an Instagram-style photo modal with a shareable URL and a full page on refresh.
- What does
(.)photo/[id]mean? - What happens on refresh vs soft navigation?
- Why did the build fail after upgrading to Next 16?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.