In this lesson you will
- Create a Next.js app and run it with next dev and next build
- Turn folders into URLs with page.tsx files
- Share a header and navigation with layout.tsx and Link
- Build dynamic pages with [segment] folders, params and generateStaticParams
Creating an app and the commands you will use
You need Node.js 20.9 or newer. In a terminal run npx create-next-app@latest my-app and accept the recommended defaults: TypeScript, ESLint, Tailwind CSS, the App Router and Cache Components. The tool creates a folder with app/layout.tsx, app/page.tsx, next.config.ts, tsconfig.json and package.json, and installs next, react and react-dom. The import alias @/* lets you write @/components/Button instead of a long relative path.
Three commands matter. npm run dev starts the development server on http://localhost:3000; it rebuilds as you save and prints each request in the terminal. npm run build makes the production build and prints a table of every route and how it was rendered. npm run start serves that build. Get used to reading the build table early: it tells you which pages are plain static HTML and which need the server at request time, and that decides how fast and how cheap your site is.
The dev terminal below is real. The request line splits the time into the part Next.js spent and the part your own code spent, which helps when a page feels slow. The console.log comes from the page component, and it printed in the terminal, not in the browser, because pages run on the server by default. Lesson 2 explains why.
import Link from "next/link";
export default function ShopsPage() {
console.log("Rendering ShopsPage");
return (
<>
<h1>Shops by city</h1>
<ul>
<li><Link href="/shops/dubai">Dubai</Link></li>
<li><Link href="/shops/sharjah">Sharjah</Link></li>
</ul>
</>
);
}â–² Next.js 16.4.6 (Turbopack)
- Local: http://localhost:3101
✓ Ready in 436ms
✓ Running next.config.ts took 44ms
- Cache Components enabled
- Partial Prefetching enabled
Rendering ShopsPage
GET /shops 200 in 422ms (next.js: 227ms, application-code: 195ms)We started the server on another port because 3000 was busy on our machine, and removed the Network line, which showed our machine address. On yours the address is http://localhost:3000.
Sign in free to read the full lesson
You are reading the free preview. Create a free account (it takes one minute, no password) to unlock the rest of this lesson and track your progress.
Unlocks after sign-in:
- 3 more sections with live code examples
- Common mistakes to avoid
- Hands-on coding exercise with automatic checks
- Practice quiz and the graded lesson test
Free forever. No card, no paywall.
Questions people ask
What is the difference between the App Router and the Pages Router?
The Pages Router is the older pages folder system. The App Router, in the app folder, is the current one: it supports layouts, Server Components, streaming and Cache Components. New projects should use the App Router, and this course teaches only it.
Which Node.js version does Next.js 16 need?
Node.js 20.9 or newer, on macOS, Windows (including WSL) or Linux. Use a current long-term support release; the examples in this course were recorded with Node.js 22.
Why are the Next.js examples not live like the React ones?
Next.js needs Node.js, a build step and a server, which cannot run safely inside a browser tab. So each example shows the files and the real output we got by running them with a pinned Next.js version. You can paste the same files into your own project and get the same result.
Should I use Link or a plain a tag in Next.js?
Use Link for pages in your own app: it prefetches and swaps pages without a full reload, and it still renders a normal <a href>. Use a plain <a> for other websites and for files you want downloaded.
Can a folder exist in app without becoming a URL?
Yes. A folder is only a public URL when it has a page.tsx or route.ts. Folders in parentheses are route groups left out of the URL, and folders starting with an underscore are private.
Sources
Facts in this lesson were checked against these official pages on 25 November 2026.
- Next.js docs: Installation
- Next.js docs: Layouts and Pages
- Next.js docs: Dynamic Route Segments
- Next.js docs: generateStaticParams
Code examples stay in English and run in a sandbox on your device. If you spot a mistake, tell us through the contact page.