Next.js Guide
How to Create a Next.js App
Next.js is the production framework for React. Here's how to create a new project in under 5 minutes — with TypeScript, Tailwind, and the App Router configured automatically.
Quick answer: Run npx create-next-app@latest my-app, answer the prompts (yes to TypeScript, ESLint, Tailwind, App Router), then cd my-app && npm run dev. Your app is live at http://localhost:3000.
📋 Before You Start
- Node.js 18.18+ — see our Install Node.js guide
- A terminal
- A code editor (VS Code)
- 5 minutes
Run create-next-app
npx create-next-app@latest my-next-app
You'll be asked a series of questions. Recommended answers:
✔ Would you like to use TypeScript? … Yes
✔ Would you like to use ESLint? … Yes
✔ Would you like to use Tailwind CSS? … Yes
✔ Would you like your code inside a `src/` directory? … No
✔ Would you like to use App Router? … Yes
✔ Would you like to use Turbopack? … Yes
✔ Would you like to customise the import alias? … No
The CLI installs dependencies and creates the full project structure. Takes 30–60 seconds.
Start the Dev Server
cd my-next-app
npm run dev
Open http://localhost:3000 in your browser. You should see the default Next.js welcome page.
The dev server hot-reloads every change instantly — no refresh needed.
Understand the Project Structure
my-next-app/
├── app/
│ ├── layout.tsx Shared layout (navbar, footer)
│ ├── page.tsx Homepage (/)
│ ├── globals.css Global styles
│ └── favicon.ico
├── public/ Static files
├── package.json
├── next.config.ts
└── tsconfig.json
Everything in app/ becomes a route. app/page.tsx is /. That's the entire routing rule.
Edit the Homepage
Open app/page.tsx and replace it with:
export default function Home() {
return (
<main className="p-10">
<h1 className="text-4xl font-bold">
Hello from Next.js!
</h1>
<p className="mt-4 text-slate-600">
This is my first Next.js page.
</p>
</main>
);
}
Save — your browser updates automatically.
Add a New Page
Create app/about/page.tsx:
export default function About() {
return (
<main className="p-10">
<h1 className="text-4xl font-bold">About</h1>
<p className="mt-4">This is my second page.</p>
</main>
);
}
Save and visit http://localhost:3000/about. You just created a route by creating a file.
Add a Navbar with Link
Edit app/layout.tsx and add inside <body>:
import Link from 'next/link';
<body>
<nav className="p-4 border-b flex gap-6">
<Link href="/" className="font-bold">Home</Link>
<Link href="/about" className="font-bold">About</Link>
</nav>
{children}
</body>
Both pages now share the same navbar. That's what a layout is — UI that wraps every page in a folder.
🧠 Key Concepts You Just Used
- File-based routing — folders become URLs
- Server Components — pages run on the server by default
- Layouts — shared UI wrapping every page
- Link component — client-side navigation with prefetching
- Tailwind works out of the box — no config needed
❓ Frequently Asked Questions
How do I create a Next.js app?
Run npx create-next-app@latest my-app. Answer the prompts and you're set in under a minute.
Pages Router vs App Router?
App Router is the modern default with React Server Components and layouts. Always use it for new projects.
Do I need TypeScript?
Not required but recommended. Next.js has first-class TypeScript support.
Which Node.js version?
Next.js 15 requires Node.js 18.18+. Use Node 20 LTS or higher.
Is Next.js free?
Yes, open source. Vercel offers free hosting.