How vercel/next-learn works
Project Type and Purpose
• This is a monorepo containing multiple Next.js example applications used in the “Learn Next.js” courses:
• basics (Pages Router starters + finals, TypeScript, dynamic routes, data fetching)
• dashboard (App Router–based starter + final examples with Auth, data seeding, CRUD)
• seo (Pages Router SEO tutorials and demo)
• Each folder under basics/, dashboard/, and seo/ is a standalone full-stack Next.js app demonstrating core concepts (SSG/SSR, API routes, App Router, Auth, Tailwind, TypeScript).
File-Structure Analysis
• Top-Level: monorepo root with versioning/config (package.json, pnpm-lock.yaml, lint/prettier configs).
• Subprojects:
• basics/…: multiple iterations of starter + final apps under pages-router.
• dashboard/…: two App Router apps (starter-example and final-example) with /app, /app/lib, /app/ui, /app/query, /app/seed, plus middleware, auth config, Tailwind.
• seo/…: pages-router SEO examples.
• Build/Deploy: each app has its own package.json, uses Next.js build scripts, optional .env, and deploy targets (Vercel).
Key Architectural Patterns & Tech
• Next.js file-system routing for both pages (/pages) and App Router (/app).
• Component-based UI under /components or /app/ui.
• Data-fetching abstractions in /lib or /app/lib (placeholder data, actions, route handlers).
• API Routes under /pages/api or route handlers under /app/query & /app/seed.
• CSS Modules, global CSS, and Tailwind CSS.
• Optional TypeScript with type declarations and tsconfig.json.
• Auth & middleware in the dashboard final example.
• Client (Browser)
• Executes React components, hydration, CSR navigation.
• Next.js Server
• Serves SSR/SSG pages, runs API routes/route handlers, middleware.
• Routing Layer
• File-based routes (/pages/*, /app/*) → rendering strategies (SSG, SSR, RSC).
• API Layer
• /pages/api/* or /app/query/route.ts & /app/seed/route.ts.
• Data Layer
• /lib/* modules: in-memory placeholder data, fetch utilities, actions.
• UI Component Library
• Shared UI primitives under /components or /app/ui (buttons, tables, forms).
• Public Assets
• Static images/CSS under /public.
• Configuration
• next.config.js, tailwind.config.js, auth.config.ts for middleware/auth.
• External Services (dashboard final)
• Auth provider (in-memory or third-party), Vercel edge functions (middleware).