Vibe coding with AI course Β· Module 2: Next.js Setup
Creating a Next.js Project with Cursor
In this lesson8
Time to create your first Next.js project! We'll use Cursor and AI to speed up the process.
What is Next.js?
Next.js is a React framework for building web applications. The official React documentation (react.dev) lists it first among the frameworks it recommends for new apps.
Why Next.js?
- Fast - Server-Side Rendering (SSR)
- Easy - routing, API routes and styling ready from the start
- SEO - great for search engines
- Hot Reload (in the docs: Fast Refresh) - changes visible instantly
- Used by - Nike, OpenAI and Sonos, among others (nextjs.org/showcase gallery)
Using AI for Project Setup
Instead of googling "how to create a Next.js project", we'll ask AI in Cursor!
Step 1: Open AI Chat
In Cursor press: Cmd/Ctrl + L
Step 2: Ask AI
Type exactly this prompt:
How do I create a new Next.js project with TypeScript and Tailwind CSS? Give me the exact npx command.Step 3: Copy the command
AI will give you a command similar to:
npx create-next-app@latest krakens-callSometimes the AI adds flags, e.g. --typescript --tailwind --app. That command works too: the installer then asks no questions and uses the recommended settings for everything else.
Step 4: Run in terminal
- Open the terminal (Ctrl + `)
- Make sure you're in the folder where you want to create the project
- Paste the command and press Enter
Step 5: Answer the installer's questions
First the installer asks whether to use the recommended settings:
Would you like to use the recommended Next.js defaults?
Yes, use recommended defaults - TypeScript, ESLint, Tailwind CSS, App Router, AGENTS.md
No, customize settings - Choose your own preferencesChoose Yes, use recommended defaults (arrow keys and Enter). You get exactly what we need: TypeScript, ESLint, Tailwind CSS and App Router (the most important one!), plus an AGENTS.md file with instructions for AI assistants.
If you choose No, customize settings, the installer asks about each option separately. Answer like this:
- TypeScript: Yes
- linter: ESLint
- React Compiler: No
- Tailwind CSS: Yes
src/folder: No- App Router: Yes (the most important one!)
- import alias: No
- AGENTS.md: Yes
Step 6: Wait (~1-2 minutes)
npm will download all packages. You'll see:
Creating a new Next.js app in /path/to/krakens-call.
Installing packages. This might take a couple of minutes.
Success! Created krakens-call at /path/to/krakens-callOpening the Project in Cursor
Method 1: Via terminal
cd krakens-call
cursor .(cursor . opens Cursor in the current folder. If the terminal doesn't know the cursor command, open the Command Palette in Cursor with Cmd/Ctrl + Shift + P, type "install cursor" and run the command that installs cursor. The code . command opens Visual Studio Code, not Cursor.)
Method 2: Via Cursor
- File β Open Folder
- Select the
krakens-callfolder - Click "Open"
Next.js 16 Project Structure
When you open the project, you'll see this structure:
krakens-call/
βββ app/ β Main application folder (App Router)
β βββ favicon.ico β Site icon
β βββ globals.css β Global CSS styles (with @import "tailwindcss")
β βββ layout.tsx β Layout (wrapper) for all pages
β βββ page.tsx β Home page (/)
βββ public/ β Static files (images, fonts)
βββ node_modules/ β Installed packages (don't commit!)
βββ AGENTS.md β Instructions for AI assistants (CLAUDE.md points to it)
βββ eslint.config.mjs β ESLint configuration
βββ next.config.ts β Next.js configuration
βββ package.json β Dependencies and scripts
βββ postcss.config.mjs β Connects Tailwind CSS
βββ tsconfig.json β TypeScript configuration
βββ .gitignore β Files ignored by GitThe most important files:
1. app/page.tsx - Home page
This is your application's home page (/). Every page.tsx file in the app/ folder is a separate page.
2. app/layout.tsx - Main layout
This is the wrapper for all pages - shared elements (e.g., header, footer).
3. app/globals.css - Global styles
CSS styles applied to the entire application.
4. package.json - Dependencies
List of all libraries + npm scripts.
5. postcss.config.mjs - Tailwind CSS
Connects Tailwind to the project. Tailwind 4 no longer has a tailwind.config.ts file: you set colors and fonts in app/globals.css.
Running the Project
Time to see the project in action!
Step 1: Install dependencies (if not done yet)
npm installStep 2: Start the development server
npm run devYou'll see:
β² Next.js 16.3.8 (Turbopack)
- Local: http://localhost:3000
- Network: http://192.168.1.10:3000
β Ready in 2.5sStep 3: Open in browser
Go to: http://localhost:3000
You'll see the default Next.js page!
Hot Reload - Next.js Magic
Hot Reload means that changes in code are visible instantly in the browser, without refreshing! In the Next.js docs this feature is called Fast Refresh.
Try it:
- Open
app/page.tsxin Cursor - Find the text "To get started, edit the page.tsx file."
- Change it to "Ahoy, Pirates!"
- Save the file (Cmd/Ctrl + S)
- Look at the browser - the change will appear automatically!
This means you can code and see the results right away. Super convenient!
App Router vs Pages Router
Next.js has two versions of routing:
| Feature | Pages Router | App Router |
|---|---|---|
| Folder | pages/ | app/ |
| Available since | the beginning, still supported | stable since Next.js 13.4 |
| Status | Older, still improved | Recommended for new projects |
| Server Components | No | Yes |
| Layouts | Difficult | Easy |
We use App Router - Next.js recommends it for new projects since version 13.4.
Summary
Next.js - React framework for building applications
npx create-next-app - creates a new project
App Router - app/ folder with routing
page.tsx - individual page
layout.tsx - shared layout
npm run dev - starts development server
Hot Reload - changes visible instantly
localhost:3000 - local application address
In the next exercise you'll learn Tailwind CSS and we'll create a landing page!
See you there!
Code for this lesson: page.tsx
// Next.js 16 App Router - Basic page structure
export default function Home() {
return (
<main className="min-h-screen p-24">
<div className="max-w-5xl mx-auto">
<h1 className="text-4xl font-bold mb-8">
Welcome to Next.js 16!
</h1>
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="border border-gray-300 p-6 rounded-lg">
<h2 className="text-2xl font-semibold mb-4">
App Router
</h2>
<p className="text-gray-600">
This is a page in the app/ folder. Each page.tsx file is a separate page.
</p>
</div>
<div className="border border-gray-300 p-6 rounded-lg">
<h2 className="text-2xl font-semibold mb-4">
Server Components
</h2>
<p className="text-gray-600">
By default, all components in App Router are Server Components.
</p>
</div>
<div className="border border-gray-300 p-6 rounded-lg">
<h2 className="text-2xl font-semibold mb-4">
TypeScript
</h2>
<p className="text-gray-600">
Next.js has built-in TypeScript support out-of-the-box.
</p>
</div>
<div className="border border-gray-300 p-6 rounded-lg">
<h2 className="text-2xl font-semibold mb-4">
Tailwind CSS
</h2>
<p className="text-gray-600">
Styling through utility classes directly in JSX.
</p>
</div>
</div>
</div>
</main>
);
}Spotted a mistake in this lesson?
Check yourself
Answer the questions from this lesson. Pick an answer to see right away whether it is correct.
1. In which folder are pages located in Next.js App Router?
2. Which command starts the development server in Next.js?
3. What is Next.js?
4. What is the app/page.tsx file in Next.js App Router?
5. What is the app/layout.tsx file responsible for?
6. What does Hot Reload mean in Next.js?
7. Which Next.js router is recommended for new projects since version 13?
Hands-on tasks in the game
- Code editor
Ask the AI in Cursor how to create a Next.js project and write the npx command you get in the commands.sh file.
- Vertical ordering
Arrange the steps for creating a Next.js project in the correct order:
- Click in order
Build the command that starts the development server:
- Vertical ordering
Arrange the steps for creating a Next.js project with AI in Cursor:
- Horizontal ordering
Arrange the command to enter the project folder (left to right):
- Click in order
Build the command that opens the current folder in Cursor:
- Horizontal ordering
Arrange the parts of the local Next.js application address (left to right):