Time to create your first Next.js project! We'll use Cursor and AI to speed up the process.
Next.js is a React framework for building web applications. It's the most popular choice in 2024.
Why Next.js?
Instead of googling "how to create a Next.js project", we'll ask AI in Cursor!
In Cursor press: Cmd/Ctrl + L
Type exactly this prompt:
1How to create a new Next.js 14 project with TypeScript and Tailwind CSS? Give me the exact npx command.AI will give you a command similar to:
1npx create-next-app@latest my-app --typescript --tailwind --app --eslintThe installer will ask about a few things:
1β What is your project named? βΊ krakens-call
2β Would you like to use TypeScript? βΊ Yes
3β Would you like to use ESLint? βΊ Yes
4β Would you like to use Tailwind CSS? βΊ Yes
5β Would you like to use `src/` directory? βΊ No
6β Would you like to use App Router? βΊ Yes
7β Would you like to customize the default import alias? βΊ NoYour answers:
krakens-call (or any name you like)npm will download all packages. You'll see:
1Creating a new Next.js app in /path/to/krakens-call...
2
3Installing packages. This might take a couple of minutes...
4
5Success! Created krakens-call at /path/to/krakens-call1cd krakens-call
2code .(
code . opens Cursor in the current folder)krakens-call folderWhen you open the project, you'll see this structure:
1krakens-call/
2βββ app/ β Main application folder (App Router)
3β βββ layout.tsx β Layout (wrapper) for all pages
4β βββ page.tsx β Home page (/)
5β βββ globals.css β Global CSS styles
6βββ public/ β Static files (images, fonts)
7βββ node_modules/ β Installed packages (don't commit!)
8βββ package.json β Dependencies and scripts
9βββ tsconfig.json β TypeScript configuration
10βββ tailwind.config.ts β Tailwind CSS configuration
11βββ next.config.js β Next.js configuration
12βββ .gitignore β Files ignored by Gitapp/page.tsx - Home pageThis is your application's home page (
/). Every page.tsx file in the app/ folder is a separate page.app/layout.tsx - Main layoutThis is the wrapper for all pages - shared elements (e.g., header, footer).
app/globals.css - Global stylesCSS styles applied to the entire application.
package.json - DependenciesList of all libraries + npm scripts.
tailwind.config.ts - Tailwind CSSTailwind configuration (colors, fonts, breakpoints).
Time to see the project in action!
1npm install1npm run devYou'll see:
1β² Next.js 14.0.0
2- Local: http://localhost:3000
3- Environments: .env.local
4
5β Ready in 2.5sGo to: http://localhost:3000
You'll see the default Next.js page! π
Hot Reload means that changes in code are visible instantly in the browser, without refreshing!
Try it:
app/page.tsx in CursorThis means you can code and see the results right away. Super convenient!
Next.js has two versions of routing:
| Feature | Pages Router | App Router | |---------|--------------|------------| | Folder |
pages/ | app/ |
| Next version | 12 and lower | 13+ |
| Status | Legacy | New standard β
|
| Server Components | β | β
|
| Layouts | Difficult | Easy |We use App Router - it's the new standard since Next.js 13/14.
β 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 addressIn the next exercise you'll learn Tailwind CSS and we'll create a landing page!
See you there! π