Installing Next.js — Complete Guide
Installing Next.js — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of Next.js Tutorial on Toolliyo Academy.
On this page
Next.js Tutorial (LearnHub) · Lesson 2 of 100
Installing Next.js
Beginner → Intermediate → Advanced → Professional
Beginner · 1 — Foundations · ~12 min read · Module 1: Next.js Foundations
Introduction
This lesson is part of the beginner section. We explain Installing Next.js slowly, with examples you can copy and run. If something is unclear, read it twice — that is how everyone learns. You install Next.js by running create-next-app, which scaffolds a TypeScript project with App Router, ESLint, and Tailwind optional. npm install downloads dependencies; npm run dev starts the local dev server on port 3000. Interviewers say "clone the repo and npm run dev" on day one. If Node or the scaffold fails, nothing else in LearnHub works.
Installing Next.js is setup knowledge. Without it, LearnHub will not run. Spend time here until npm run dev works without errors.
When will you use this?
You need this before writing any Next.js code — same as installing Node.js before opening a project.
- Every React/Next.js job expects you to run npx create-next-app and npm run dev on day one.
- Interviewers often ask you to explain the App Router folder structure and Server vs Client Components.
Real-world: ShopNest storefront
The E-commerce team building ShopNest storefront uses Installing Next.js to scaffold the LearnHub app with TypeScript and App Router in one command. customers and admins never see the TypeScript files — they just get a fast, reliable product pages, cart, and checkout flow.
Production-style code
npx create-next-app@latest learnhub
# Choose: TypeScript Yes, ESLint Yes, Tailwind Yes,
# src/ No, App Router Yes, import alias @/* Yes
cd learnhub
npm run dev
# Open http://localhost:3000
What happens in production: In ShopNest storefront, a solid Installing Next.js foundation lets the team ship product pages, cart, and checkout flow on schedule without toolchain surprises.
Lesson example (start here)
Copy this smaller example first. Once it works, compare it with the real-world code above.
npx create-next-app@latest learnhub
# Choose: TypeScript Yes, ESLint Yes, Tailwind Yes,
# src/ No, App Router Yes, import alias @/* Yes
cd learnhub
npm run dev
# Open http://localhost:3000
Line-by-line walkthrough
| Code | What it means |
|---|---|
npx create-next-app@latest learnhub | Part of the Installing Next.js example — read it together with the lines before and after. |
# Choose: TypeScript Yes, ESLint Yes, Tailwind Yes, | Comment — notes for humans; the compiler ignores it. |
# src/ No, App Router Yes, import alias @/* Yes | Comment — notes for humans; the compiler ignores it. |
cd learnhub | Part of the Installing Next.js example — read it together with the lines before and after. |
npm run dev | Part of the Installing Next.js example — read it together with the lines before and after. |
# Open http://localhost:3000 | Comment — notes for humans; the compiler ignores it. |
How it works (big picture)
- create-next-app copies the official template.
- npm run dev watches files and hot-reloads the browser.
- The first page is app/page.tsx.
Do this on your computer
- Run npx create-next-app@latest learnhub with options above
- cd learnhub
- Run npm run dev
- Open http://localhost:3000 and see the default page
- Edit app/page.tsx heading to "LearnHub" and save — watch it update
- Read the real-world section and name which part of LearnHub uses this topic.
- Run the example locally with npm run dev and confirm the same behavior.
- Change one value in the example (route, text, or course id) and predict what will happen before you save.
Experiments — try changing this
- Change a string or route in the example and save — watch the browser update.
- Break the code on purpose (remove a bracket), read the error overlay, then fix it.
Remember
create-next-app scaffolds the project. npm run dev is your daily command. Use TypeScript and App Router for LearnHub.
Common questions
pnpm or yarn instead of npm?
All work — npm is fine for learning. Use what your team standardizes on.
Port 3000 already in use?
Stop the other process or run npm run dev -- -p 3001