Exp 09 — nested routes
Three routes under one node.
This heading is rendered by a Layout two levels down from the document. The root Layout wrote the <html> around it; this one wraps every route under /builds, and the component below is whichever one matched.
- Layout sees
- /builds
- Params, from getContext()
- {}
Live specimen — builds/index.server.tsx
- a1 · the walking skeletongreen · 41s
- b2 · a Client module and its preloadgreen · 38s
- c3 · Awakening and dispatchred · 52s
- d4 · the Server boundarygreen · 47s
Two children sit under this node and both of them match the URL /builds/new: a static new and a param :id. Static beats param, left to right, and the route table is sorted at build time — so declaration order is never consulted and the static one wins however the two are written.
The same records are served as JSON by an API route, which renders nothing and enters no Walk: /api/builds answers GET and POST, and /api/builds/:id answers GET. That node carries no component at all, so a method it does not handle is a 405 rather than a page.