Menu

Setting Up Your First Next.js Project

Lesson 4: Setting Up Your First Next.js Project

What do you need?

Requirement

Minimum version

Check with

Node.js20.9node -v
Package managernpm (comes with Node), pnpm, yarn, or bunnpm -v
Code editorAny; VS Code is common–
BrowserChrome, Edge, or Firefox 111+, Safari 16.4+–

Example

Create a project named learnhub:

npx create-next-app@latest learnhub

The installer asks a few questions. The recommended defaults are:

Prompt

Recommended answer

Why

TypeScriptYesCatches errors early; most examples use it
ESLintYesFlags common mistakes
Tailwind CSSYesFast styling; covered in Module 4
src/ directoryOptionalKeeps app code separate from config files
App RouterYesThe current routing system
TurbopackDefaultFaster dev server and builds
Import alias @/*YesLets you write @/components/... instead of ../../

Then start the development server:

cd learnhub
npm run dev

Open http://localhost:3000 in your browser. Edit app/page.tsx, save, and the page updates without a full reload.

How it works

Command

What it does

When to use

npm run devStarts the dev server with Fast RefreshWhile writing code
npm run buildCreates an optimised production build and type-checksBefore deploying
npm run startServes the production buildTo test production locally or on a server
npm run lintRuns ESLint directlyBefore committing
  • Since Next.js 16, next build no longer runs the linter. Run ESLint (or Biome) yourself or in CI.
  • Turbopack is the default bundler. If an old project needs webpack, use next dev --webpack.

Common mistakes

Mistake

Problem

Fix

Old Node.js versionInstall or build failsUpgrade to Node 20.9+ (an LTS release is safest)
Testing performance with npm run devDev mode is slower and unoptimisedUse npm run build && npm run start
Port 3000 already in useDev server picks another port or failsStop the other process or run npm run dev -- -p 3001
Committing node_modules or .nextHuge repositoryKeep the generated .gitignore

Key takeaways

  • create-next-app sets up a working project with good defaults in one command.
  • Use dev while building, and build + start to check real performance.

Try it: Create the learnhub project, change the home page heading to "Welcome to LearnHub", and run a production build.


Nextjs Tutorial

J

Jebasta





Get in Touch For Details