Summary#
Closes #5351 — new users following the "build from scratch" getting-started flow get stuck because the guide never connects the layout route concept to the <Outlet /> component.
The "Creating File Routes" table lists posts.tsx as a "Layout" route, and the "Nested Routing" section shows the component tree <Root><Posts><Post /></Posts></Root> — but the route generator creates a placeholder component for posts.tsx that does not include <Outlet />. So when a user follows the guide and navigates to /posts/123, only the posts.tsx component renders and the child route never appears. The <Outlet /> component is documented elsewhere in the same guide but isn't bridged to the layout-route concept in the flow new users actually follow.
The fix#
Two small additions to docs/start/framework/react/guide/routing.md:
- A
> [!NOTE] callout after the "Creating File Routes" table explaining that a layout route's component must render <Outlet />, with a runnable posts.tsx example.
- A line under "Nested Routing" stating that the
posts.tsx layout component must render <Outlet /> for <Post /> to display.
Both link to the existing #defining-routes anchor where <Outlet /> is shown.
Note#
I see there's a draft PR (#7831) touching this area — happy to coordinate or withdraw if that one progresses; this PR is an independent, self-contained docs addition.
AI usage#
An AI assistant was used to help locate the relevant code and draft this change. I have reviewed and understand every line of the diff, and I am the sole author of this contribution.
Closes #5351
Summary by CodeRabbit#
- Documentation
- Clarified nested routing behavior and the requirement to render an
<Outlet /> for child routes to appear.
- Added guidance explaining layout routes and route generator behavior.
- Included a practical example of using
<Outlet /> in a layout route.
📝 Walkthrough
Walkthrough#
The React routing guide now explains that
posts.tsxis a layout route and must render<Outlet />for matching child routes to appear. It also documents the generated placeholder behavior and provides a corrected layout example.Changes#
Nested routing guide
docs/start/framework/react/guide/routing.md<Outlet />inposts.tsx, explains the generator-created placeholder, and adds a complete layout example.Estimated code review effort: 1 (Trivial) | ~2 minutes
Suggested labels:
package: router-generator🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
#5351.✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share