Stage 4
Stage 4: Routing and Application Architecture
✅ Complete. Every part below has its full lesson (
README.md),examples/,exercises.mdandsolutions/, and the examples and solutions were actually run — see each part's README for real, captured output and../TOOLING.mdfor the verified toolchain.
Goal: Turn a single-screen app into a real multi-page client-side app, and learn to structure a growing codebase so it doesn't collapse under its own state. Time: ~9 h of lessons + ~8–10 h capstone (~17–19 h total) at 1–1.5 hours a day · Level: Stage 3 done (fetching, performance, error boundaries, testing)
Scope boundary: this stage stops at client-side routing (React Router, rendered entirely in the browser). Server-side rendering, file-based routing, and React Server Components belong to the planned Next.js course — see
DESIGN-NOTES.md.
Parts in this stage
| Part | Topic | Learning outcomes | Time |
|---|---|---|---|
| 15 | React Router | Set up a router; define routes and nested routes; read URL params; navigate with <Link>/useNavigate; build a "protected route" that redirects when a (mock) auth state is missing; build a catch-all 404 route |
~5 h |
| 16 | Structuring a growing app | Reorganize a project into feature folders instead of type folders (components/, hooks/, pages/); read a decision-tree note on when useContext/useReducer stop being enough and a state-management library earns its weight; handle environment variables and a basic static-host deploy |
~4 h |
Prerequisites for this stage
- Stage 3 complete: data fetching with loading/error states, error boundaries, a working test suite
- At least one multi-component project already built (Stage 2 or 3's project) to reorganize/extend
Stage 4 capstone {#capstone}
Bookstore SPA — the course's main capstone. A multi-page, router-driven, fully client-rendered app, e.g.:
/— a searchable, filterable list (reuses Stage 3's fetching patterns)/items/:id— a detail route read from the URL param/favorites— a route backed by the Stage 2 reducer/context pattern (favorite/cart-like state)- A protected
/adminor/accountroute behind a mock login - A 404 route
- A real test suite (Stage 3's testing patterns) covering at least the list, detail, and protected-route redirect
Acceptance sketch (the project README has the final checklist):
- At least 4 distinct routes, including one dynamic (
:id) and one protected - Shared state (favorites/cart) persists correctly across route changes
- Project is organized in feature folders, not one flat
components/dump - Deployed to a static host (e.g. Vercel/Netlify/GitHub Pages) with a documented one-command deploy
- Test suite passes and covers at least one routing-dependent behavior (e.g. redirect-when-not-logged-in)
This capstone is the project most students show in an interview — it is the natural "is this person job-ready at React" checkpoint before Stage 5.