In the previous lesson you saw what Next.js adds to React. Now you'll create the project that will accompany you throughout the course: agendaviva, the cultural events guide for a fictional city. The official generator gives you a working application in a couple of minutes, but it makes many decisions on your behalf, and knowing what they are saves you surprises later on.

You'll see what each recommended value means, what the configuration files contain, how the three main commands (dev, build and start) differ and which tools you have for finding errors: Fast Refresh, the error overlay, the development indicator, TypeScript and ESLint.

  1. Requirements

Requirement Minimum Recommendation for the course
Node.js 20.9 An LTS version that is still supported
TypeScript 5.1 Whatever the generator installs
Operating system macOS, Linux or Windows (WSL too) The one you normally use
Package manager npm, pnpm, yarn or bun npm, which ships with Node.js
Editor Any with TypeScript support VS Code or similar

Check your Node.js version before you start:

node --version

If it's older than 20.9, update it from nodejs.org or with a version manager. The course uses npm throughout; if you prefer another package manager, the commands are equivalent (pnpm dev, yarn dev…).

  1. Creating the project with create-next-app

Go to the folder where you keep your projects and run:

npx create-next-app@latest

npx downloads and runs the generator without installing it permanently, and @latest makes sure you use the newest one instead of one left over in the npm cache. Answer agendaviva for the name and pick the first option for the second question:

What is your project named? agendaviva
Would you like to use the recommended Next.js defaults?
    Yes, use recommended defaults - TypeScript, ESLint, No React Compiler, Tailwind CSS,
      No src/ directory, App Router, Cache Components, AGENTS.md, Agent feedback
    No, reuse previous settings
    No, customize settings - Choose your own preferences

The "reuse previous settings" option only appears if you've used the generator before: it stores your preferences. When it finishes, it installs the dependencies, creates a Git repository and shows the steps to get started.

Value What it implies Why we accept it
TypeScript .ts and .tsx files, configuration ready Next.js generates types for your routes; without TypeScript you lose them
ESLint Rules for Next.js, React and hooks Catches errors the compiler doesn't see
No React Compiler No automatic memoization It's optional and we don't need it to learn
Tailwind CSS Utility classes already configured Gives an acceptable look without writing CSS
No src/ folder app/ sits at the root Fewer levels; it's just a preference
App Router app/ folder It's the course's routing system
Cache Components cacheComponents and partialPrefetching enabled It's the current rendering model (module 5)
AGENTS.md Instructions for coding assistants Points to the documentation for your exact version
Agent feedback Experimental reporting option We'll turn it off in section 4

Two more values are applied without asking: Turbopack as the bundler and the @/* import alias.

2.2. Creating it without prompts

If you automate project creation (in a script, or in a team that wants identical projects), pass each decision as an option. The following line produces the course project with no dialog:

npx create-next-app@latest agendaviva \
  --ts --eslint --tailwind --app --cache-components \
  --no-src-dir --no-react-compiler --import-alias "@/*" \
  --agents-md --no-agent-feedback --use-npm

There's also --yes, which skips the prompts, but it uses your saved preferences if there are any: two people can get different projects from the same command. --reset-preferences clears those preferences.

  1. What has been generated

agendaviva/
├── app/
│   ├── favicon.ico
│   ├── globals.css        Global styles (imports Tailwind)
│   ├── layout.tsx         Root layout: <html> and <body>
│   └── page.tsx           Home page, route /
├── public/                Files served as-is
├── node_modules/
├── .gitignore
├── AGENTS.md              Instructions for assistants
├── README.md
├── eslint.config.mjs      ESLint rules
├── next-env.d.ts          Next.js types (generated)
├── next.config.ts         Next.js configuration
├── package.json
├── package-lock.json
└── tsconfig.json          TypeScript configuration

The structure of app/ and its conventions are the subject of lesson 01-03. Here we focus on the configuration files.

3.1. package.json and the scripts

{
  "name": "agendaviva",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "eslint"
  },
  "dependencies": {
    "next": "16.4.6",
    "react": "19.3.0",
    "react-dom": "19.3.0"
  },
  "devDependencies": {
    "@tailwindcss/turbopack": "^4",
    "@types/node": "^20",
    "@types/react": "^19",
    "@types/react-dom": "^19",
    "eslint": "^9",
    "eslint-config-next": "16.4.6",
    "tailwindcss": "^4",
    "typescript": "^5"
  }
}

Your patch numbers will depend on when you create the project. Notice two details. First, next and eslint-config-next have the same exact version: when you upgrade one, upgrade the other. Second, the App Router uses a version of React built into Next.js itself; even so, react and react-dom must be listed here because other tools and libraries look for them in your project.

Add two scripts we'll use often:

"lint": "eslint",
"lint:fix": "eslint --fix",
"typecheck": "next typegen && tsc --noEmit"

next typegen generates your route types without building the application, and tsc --noEmit checks types without writing any files. Together they validate the whole project in very little time.

3.2. tsconfig.json and the @/ alias

The generator turns on strict mode ("strict": true), the module resolution that Turbopack understands and a Next.js plugin for the editor. These are the parts worth recognizing:

{
  "compilerOptions": {
    "strict": true,
    "noEmit": true,
    "moduleResolution": "bundler",
    "jsx": "react-jsx",
    "plugins": [{ "name": "next" }],
    "paths": {
      "@/*": ["./*"]
    }
  },
  "include": [
    "next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.mts",
    ".next/types/**/*.ts", ".next/dev/types/**/*.ts"
  ],
  "exclude": ["node_modules"]
}
  • paths defines the alias: @/lib/types means lib/types from the project root, wherever you write the import. It avoids paths like ../../../lib/types, which break when you move a file.
  • include pulls in the types Next.js generates inside .next. That's where PageProps, LayoutProps and RouteContext come from: global types that you don't import and that know your routes.
  • plugins makes the editor flag Next.js-specific errors, such as using useState in a Server Component. In VS Code, open the command palette, choose "TypeScript: Select TypeScript Version" and then "Use Workspace Version" so that it loads.

The next-env.d.ts file is regenerated by the framework: don't edit it or commit it to the repository (the generated .gitignore already excludes it).

  1. next.config.ts

This file is the framework's configuration. It's typed with NextConfig, so the editor suggests options and warns you if you write one that doesn't exist. With the recommended values it contains the Cache Components flags, the rule that connects Tailwind to Turbopack and the experimental reporting option. Leave it like this:

import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  // Current rendering and caching model (module 5)
  cacheComponents: true,
  // Prefetch one shell per route instead of per link (module 10)
  partialPrefetching: true,
  turbopack: {
    rules: {
      // Process CSS with Tailwind
      '*.css': {
        loaders: ['@tailwindcss/turbopack'],
        as: '*.css',
      },
    },
  },
}

export default nextConfig
  • cacheComponents: true enables the model in which data is read on every request unless you mark it with 'use cache', and in which Next.js requires every uncached data wait to sit inside a <Suspense> so it can prerender the rest.
  • partialPrefetching: true complements the previous flag for link prefetching. It must be declared explicitly: if it's missing, Next.js shows a warning. It requires cacheComponents.
  • turbopack.rules replaces the old postcss.config.mjs. Don't touch it: without it, Tailwind classes wouldn't generate any styles.

We've removed the experimental: { agentFeedback: true } block that the generator adds. It lets a coding assistant draft issue reports for the Next.js team, always subject to your review before anything is sent; since it's experimental and adds nothing to the course, we'll do without it.

Changes to next.config.ts affect server startup. If one doesn't seem to take effect, stop next dev and start it again.

  1. The three commands: dev, build and start

Command Purpose Characteristics
npm run dev Develop Compiles on demand, reloads on save, shows detailed errors, doesn't optimize
npm run build Prepare for production Checks types, compiles, prerenders routes and writes .next/
npm run start Serve production Starts the server with whatever build produced

5.1. Development

cd agendaviva
npm run dev

Open http://localhost:3000 and you'll see the sample page. The server compiles each route the first time you visit it, so that first visit takes a bit longer. To change the port, add -- and the option, because npm needs that separator to pass it on to Next.js:

npm run dev -- -p 4000

Development output is stored in .next/dev, separate from the production output, so you can run npm run build without stopping the development server.

5.2. Production build

npm run build

next build loads the configuration, discovers the routes, compiles, checks types, prerenders what it can and ends with a table. The symbols show how much HTML was produced for each route with Cache Components enabled:

Symbol Name Meaning
○ Static The whole route was prerendered as HTML
◐ Partial Prerender There's an HTML shell; the rest is resolved on every request
ƒ Dynamic Rendered entirely on every request

In the freshly created project, the home page is static:

Route (app)
┌ ○ /
└ ○ /_not-found

○  (Static)  prerendered as static content

That table will be your main reference in module 5. A type error stops the build; an ESLint warning doesn't, because next build no longer runs the linter.

5.3. Serving the output

npm run start

next start only serves what build generated. If you change code, you have to rebuild. Get into the habit of testing this way before calling something done: link prefetching, caching and prerendering don't behave the same in development, where almost everything is recomputed so you can see your changes.

  1. Turbopack and Fast Refresh

6.1. Turbopack

Turbopack is the bundler built into Next.js, written in Rust, and the default for both dev and build since version 16. It works incrementally: it caches the result of every operation, on disk too between runs, and in development it only compiles what is requested. It reads the alias from tsconfig.json with no extra configuration.

It doesn't run Webpack plugins or recognize the webpack() key in the configuration. If a project depends on them, it can fall back to Webpack with next dev --webpack and next build --webpack. You won't need that in this course.

One detail worth remembering: Turbopack doesn't check types in development. It transforms the TypeScript and moves on. You'll see type errors in the editor, with npm run typecheck or when you build.

6.2. Fast Refresh

With the development server running, open app/page.tsx, change some text and save: the browser updates without reloading. Fast Refresh swaps in the edited module and preserves the state of client components whenever it's safe to do so. The practical rules are:

  • If the file only exports components, that component is updated and its state is preserved.
  • If it also exports other things (constants, functions), that file and the ones that import it are re-run.
  • If it's imported by code outside the React tree, the whole page reloads.
  • Anonymous components (export default () => …) and class components lose their state. Always give them a name.
  • Effects re-run on every edit, even if their dependencies haven't changed.

To force a component to remount on every edit, add the comment // @refresh reset to its file.

  1. Seeing and understanding errors

7.1. The development indicator

The Next.js indicator appears in the bottom-left corner, and it only exists in development. It gives context about the current route and opens the Next.js DevTools. Among them is the Navigation Inspector, which freezes the page in its initial loading state so you can see the static shell; we'll use it in module 4. You can move it with devIndicators: { position: 'bottom-right' } or hide it with devIndicators: false; even when hidden, build and runtime errors are still shown.

7.2. The error overlay

When an error occurs, Next.js overlays a panel with the message, the code snippet and the call stack mapped to your files. Depending on the source:

Type Example How to fix it
Build A missing brace, an import that doesn't exist Fix it and save: the overlay goes away by itself
Runtime Cannot read properties of undefined The stack points to the line; if it failed during rendering, the tree is remounted
Hydration The server HTML doesn't match the client HTML Look for values that differ between the two (dates, random numbers)
Prerendering Uncached data outside <Suspense> The overlay suggests the possible fixes

The last type is specific to Cache Components and you'll run into it soon. Rather than just telling you what's wrong, the overlay offers cards with the ways out: wrap it in <Suspense> (stream), cache it (cache) or allow the route to block (block), each with a link to its explanation. Read the whole message before choosing.

Errors and warnings from the browser console are also forwarded to the terminal where next dev is running.

7.3. ESLint

The generator creates eslint.config.mjs with the rules for Next.js, React and TypeScript:

import { defineConfig, globalIgnores } from 'eslint/config'
import nextVitals from 'eslint-config-next/core-web-vitals'
import nextTs from 'eslint-config-next/typescript'

const eslintConfig = defineConfig([
  ...nextVitals,
  ...nextTs,
  globalIgnores(['.next/**', 'out/**', 'build/**', 'next-env.d.ts']),
])

export default eslintConfig

core-web-vitals turns the rules that affect perceived performance into errors, and typescript adds the typescript-eslint rules. Run it with npm run lint.

The next lint command was removed in Next.js 16, along with the eslint key in next.config. If a guide mentions them, it predates that release. Since the build no longer runs the linter, it's up to you: install the ESLint extension in your editor and include it in continuous integration (lesson 11-06).

  1. AGENTS.md

AGENTS.md is an instructions file that coding assistants read when they open the project. Next.js ships its complete documentation, for the exact version you have installed, in node_modules/next/dist/docs/, and the managed block in AGENTS.md tells the assistant to consult it before writing code. The reason is the same one that made you check the version of tutorials: a model trained on old material suggests APIs that no longer exist.

<!-- BEGIN:nextjs-agent-rules -->
…instructions managed by Next.js…
<!-- END:nextjs-agent-rules -->

## AgendaViva project rules
- Names, comments and UI text in English.
- Data is read only through lib/data/.

next dev maintains the content between the markers and leaves the rest alone, so you can add your team's rules below. If you don't want the block, agentRules: false in the configuration removes it. Even if you don't use assistants, that local documentation is handy for looking things up offline.

Common Mistakes and Tips

  • Installing an old version of the generator. Without @latest, npx may reuse a cached copy and create a project from another era.
  • Testing only with npm run dev. Type and prerendering errors that break the build can go unnoticed if you don't visit the affected route. Run npm run build often.
  • Running npm run start without building, or expecting it to reflect changes made after the last build.
  • Forgetting the -- when passing options through npm. npm run dev -p 4000 doesn't pass the option on to Next.js.
  • Assuming the linter runs during the build. It no longer does.
  • Editing next-env.d.ts or files inside .next. They're regenerated and you'll lose your changes. If you need to declare your own types, create another .d.ts file.
  • Importing with different casing from the file name. ./Header and ./header may work on macOS or Windows and fail on Linux. In this course, file names are always lowercase with hyphens.

Exercises

Exercise 1: creating and verifying the project

Create the agendaviva project, remove the experimental reporting option, add the lint:fix and typecheck scripts and check that everything is in order. Which commands do you run and what does each one verify?

Solution

npx create-next-app@latest agendaviva
cd agendaviva
# …edit next.config.ts and package.json…
npm run lint
npm run typecheck
npm run build
npm run start

lint checks the ESLint rules; typecheck generates the route types and checks TypeScript; build confirms that the application compiles and that its routes can be prerendered; start serves it as in production. Running them in that order surfaces the cheapest failures first.

Exercise 2: breaking things on purpose

With npm run dev running, introduce these three errors in app/page.tsx one at a time and note where each one shows up (browser overlay, terminal, editor or npm run build):

  1. Delete the parenthesis that closes the return.
  2. Add const total: number = 'five' and render {total}.
  3. Throw throw new Error('Test') at the start of the component.

Solution

  1. Syntax: a build error. The editor, the terminal and the overlay all show it; it disappears when you fix it and save.
  2. Types: the editor flags it, but the page still renders in development, because Turbopack doesn't check types. It will show up with npm run typecheck and will break npm run build.
  3. Runtime: an overlay with the call stack pointing to the line, and the same error in the terminal, since the page is a Server Component and runs on the server. It would also make build fail, because the page is prerendered at build time.

The second case is what justifies having a well-configured editor and the typecheck script.

Exercise 3: using the alias

Create lib/site.ts with a SITE_NAME constant and display it in app/page.tsx, importing it through the alias. Then explain what you'd have to change if the page file were moved into a subfolder of app/.

Solution

// lib/site.ts
export const SITE_NAME = 'AgendaViva'
// app/page.tsx
import { SITE_NAME } from '@/lib/site'

export default function HomePage() {
  return <h1>{SITE_NAME}</h1>
}

Nothing would need to change: @/lib/site is resolved from the project root. With a relative path (../lib/site) you'd have to add one level for each subfolder. Keep lib/site.ts: we'll use it in lesson 01-04.

Conclusion

You've created the project with the recommended values and you know what each one decides: TypeScript with generated route types, ESLint that you run yourself, Tailwind wired into Turbopack, and Cache Components with partial prefetching as the rendering model. You can tell the development server, which favors speed and diagnostics, from the production build, which checks types and prerenders, and you know the tools that will tell you what's failing and where.

What's left is to understand the most important folder. In the next lesson, Project Structure and File Conventions, you'll see what each name means inside app/ and how we'll organize the rest of the code.

© Copyright 2026. All rights reserved