Free lesson

Create routes and real navigation

Create routes and real navigation — Build a Next.js website with an AI assistant. Folders define routes; Save two pages; Check refresh and unknown paths. Practical assignment: Lab evidence.

Demo edition. The materials are undergoing editorial review.

Topics covered

  • Folders define routes
  • Save two pages
  • Check refresh and unknown paths

Folders define routes

In App Router, app/page.tsx serves the home route and app/workshops/page.tsx serves /workshops. A component filename alone does not create a route.

The fictional site lists a clay workshop and demonstrates local form validation without creating a real reservation. Keep that distinction visible in the interface. Ask the assistant for changes to named files and explain whether each file executes on the server or in the browser. A framework can render a polished page while still exposing secrets, losing form errors or linking to missing routes; inspect those behaviors directly.

Save two pages

Replace the generated home and create the workshops directory. These are Server Components by default. Use actual Link destinations rather than click handlers for navigation.

A page component must have a default export in its route folder. Keep the root layout supplied by the generator because it provides the document shell and imports global CSS. A missing layout error is structural; adding use client cannot repair a nonexistent route or document shell.

Apply snippets in the named App Router paths and retain generated configuration unless the lesson explicitly changes it. Run the development server while editing, then inspect terminal and browser errors separately. Imports are relative to the shown file tree. Keep a small commit before each feature so an assistant mistake can be removed without reconstructing the entire project. Do not put private credentials into client-visible environment variables.

// app/page.tsx
import Link from 'next/link';
export default function Home(){return <main><h1>Workshop demo</h1><p>Fictional training site.</p><Link href="/workshops">See workshops</Link></main>;}
// app/workshops/page.tsx
import Link from 'next/link';
export default function Workshops(){return <main><h1>Clay workshop</h1><p>Tuesday, six places. Fictional example.</p><Link href="/">Home</Link></main>;}

Check refresh and unknown paths

Open /workshops directly, refresh and return home. Open a nonexistent path and confirm a real not-found response rather than fabricated workshop details.

Verify direct navigation, refresh and form failure states, not only clicks during one development session. Development hot reload can hide assumptions that fail in a production build. Preserve error messages as visible text and never replace an error with a success banner. This lab does not persist submissions; a real data mutation additionally needs authentication, authorization, durable storage and an explicit privacy policy. Record which parts are implemented.

Practical assignment

Lab evidence

Continue to learning

Course outline

  1. Scaffold and record the environment
  2. Create routes and real navigation
  3. Keep interactivity at a client boundary
  4. Validate a demo form on the server
  5. Review accessibility and production errors
  6. Build and choose a compatible deployment