Stage 4
Stage 4: Full-Stack Next.js
Content wave complete. Parts 13–16 and the QuickCart capstone are written, built, and verified against this harness — see each part's own README for real, captured output.
Goal: Build the server side of an app — APIs, request middleware, an auth pattern, and a real database — entirely inside Next.js, with no separate backend service. Time: ~25 h of lessons + ~10 h capstone (~35 h total) at 1–1.5 hours a day · Level: solid on Stage 3's data/caching/actions model
Parts in this stage
| Part | Topic | Learning outcomes | Time |
|---|---|---|---|
| 13 | Route Handlers (API routes) | Write a route.ts file under app/api/... with GET/POST handlers; work with the Request/Response objects; decide when a Route Handler is the right tool versus a Server Action |
~6 h |
| 14 | Middleware and the request pipeline | The file convention is actually proxy.ts on this pinned version (middleware.ts was deprecated/renamed in Next.js 16 — both are built and compared for real); scope it with a matcher; perform redirects and rewrites; read and write cookies/headers before a request reaches a page |
~6 h |
| 15 | An auth pattern | Implement session cookies with iron-session (chosen with the same npm-evidence standard DESIGN-NOTES.md used for better-sqlite3); protect a route group/layout — and prove, with a reproduced finding, why a layout's own check alone is not enough; check authentication in a Server Component vs in middleware, measured side by side, not just described |
~6 h |
| 16 | Database integration | Set up better-sqlite3; write a small data-access layer (not raw queries scattered through components); call it from a Server Component, a Server Action, and a Route Handler; explain why a synchronous SQLite driver is a simple, dependency-light fit for this course's capstones — and reproduce the installed docs' own named gotcha for synchronous drivers under Cache Components |
~7 h |
Prerequisites for this stage
- Stage 3 (data fetching, caching, revalidation, Server Actions)
- Nothing from backend frameworks, SQL, or auth libraries is assumed — all taught from the Next.js side
Stage 4 capstone: QuickCart
A small, full-stack e-commerce slice that proves Stages 3–4 work together — built, run, and verified; see project-quickcart/README.md for the implementation map and project-quickcart/tests_manual.md for the full real-output transcript.
Acceptance checklist (finalized, every item ticked from observed behavior):
- Product listing and detail pages are Server Components (Part 9) with caching applied to at least one expensive read (Part 10)
- Adding/removing a cart item goes through a Server Action (Part 12), not a client-side
fetch - An admin-style edit to a product revalidates the public page that shows it (Part 11)
- Checkout is gated behind the Part 15 auth pattern — an unauthenticated visitor is redirected, not shown a broken page
- A Route Handler (Part 13) exposes a read-only, JSON order-status endpoint, testable with
curl - Cart and order data persist to SQLite (Part 16) and survive a server restart