You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Nextjs/intro-nextjs.md
+20-30Lines changed: 20 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,3 @@
1
-
---
2
-
id: intro-nextjs
3
-
title: Introduction to Next.js
4
-
sidebar_label: Introduction to Next.js
5
-
sidebar_position: 1
6
-
tags:
7
-
- Next.js
8
-
- Introduction to Next.js
9
-
- What is Next.js
10
-
- Why learn Next.js
11
-
- How to use Next.js
12
-
description: Learn about Next.js, the powerful React framework for building production-ready web applications. Discover its features, benefits, rendering strategies, and how to get started with your first project.
13
-
---
14
-
15
1
**Next.js** is a production-ready React framework that revolutionizes how we build modern web applications. Created and maintained by [Vercel](https://vercel.com), Next.js extends React's capabilities by providing a robust, opinionated structure that handles the complexities of production deployment, performance optimization, and developer experience out of the box.
16
2
17
3
## What Makes Next.js Special?
@@ -27,7 +13,7 @@ Unlike vanilla React applications that require extensive configuration and addit
27
13
- 🛠️ **Full-Stack Capabilities** - Build APIs alongside your frontend using API Routes or Server Actions
28
14
- 📦 **Production-Ready** - Optimized builds and seamless deployment with Vercel or any Node.js hosting
29
15
30
-
Next.js offers both <ahref="https://nextjs.org/docs/getting-started">free</a> and commercial hosting solutions through Vercel, with features like automatic deployments, edge functions, real-time analytics, and global CDN distribution.
16
+
Next.js offers both <ahref="https://nextjs.org/docs">free</a> and commercial hosting solutions through Vercel, with features like automatic deployments, edge functions, real-time analytics, and global CDN distribution.
31
17
32
18
:::
33
19
@@ -55,7 +41,6 @@ While alternatives like Gatsby (static sites), Remix (web standards focus), and
55
41
56
42
One of Next.js's most powerful features is its **flexible rendering approach**. Let's understand this with a real-world example:
57
43
58
-
:::info
59
44
**E-commerce Application Example:**
60
45
61
46
Imagine you're building an online store. Different pages have different requirements:
@@ -80,11 +65,14 @@ Imagine you're building an online store. Different pages have different requirem
80
65
- Leverages browser capabilities
81
66
82
67
Next.js empowers you to **mix and match** these strategies within the same application, choosing the optimal approach for each page. This flexibility is what makes Next.js stand out from other frameworks.
@@ -102,7 +90,6 @@ However, React alone doesn't provide:
102
90
103
91
This is where **React frameworks** like Next.js come into play.
104
92
105
-
:::info
106
93
**Understanding React Frameworks:**
107
94
108
95
Think of React as the **engine** of a car - powerful and essential, but not sufficient on its own. To build a complete, roadworthy vehicle, you need wheels, steering, transmission, suspension, and countless other components.
@@ -176,7 +163,6 @@ You can build **any type** of web application with Next.js:
176
163
177
164
Let's explore what makes Next.js a comprehensive framework:
178
165
179
-
:::info
180
166
**Feature Categories:**
181
167
182
168
**1. Routing System**
@@ -214,8 +200,6 @@ Let's explore what makes Next.js a comprehensive framework:
214
200
215
201
Next.js **automates the hard parts** of web development, allowing you to focus on creating amazing user experiences rather than wrestling with configuration and optimization.
216
202
217
-
:::
218
-
219
203
## Getting Started: Your First Next.js Project
220
204
221
205
### Prerequisites
@@ -225,10 +209,14 @@ Before creating a Next.js application, ensure you have:
225
209
- A code editor (VS Code recommended)
226
210
- Basic knowledge of React, JavaScript/TypeScript, and HTML/CSS
227
211
212
+
**New to React?** Don't worry! While Next.js is built on React, you can learn both simultaneously. Start with basic React concepts like components, props, and state, then gradually explore Next.js features. The [React documentation](https://react.dev/learn) is an excellent resource to get started.
213
+
228
214
### Installation and Setup
229
215
230
216
Creating a new Next.js project is straightforward with the official `create-next-app` tool:
231
217
218
+
**What is npx?** It's a package runner tool that comes with npm (Node Package Manager). It allows you to run packages without installing them globally. Think of it as a way to execute commands directly from the npm registry.
219
+
232
220
```bash
233
221
# Create a new Next.js app with the latest version
234
222
npx create-next-app@latest my-next-app
@@ -250,14 +238,14 @@ npm run dev
250
238
251
239
Your Next.js application will be running at `http://localhost:3000` with hot reloading enabled.
252
240
253
-
:::tip
241
+
**What is localhost:3000?** This is your local development server. `localhost` refers to your own computer, and `3000` is the port number. Open your web browser and type this address to see your application. Hot reloading means changes you make to your code will automatically appear in the browser without manual refresh!
242
+
254
243
**Quick Start Recommendations:**
255
244
- ✅ Use **TypeScript** for better type safety and developer experience
256
245
- ✅ Use **ESLint** to catch errors early
257
246
- ✅ Use **Tailwind CSS** for rapid UI development
258
247
- ✅ Use **App Router** (Next.js 13+) for the latest features
259
248
- ✅ Enable **`src/` directory** for cleaner project organization
260
-
:::
261
249
262
250
### Understanding the Project Structure
263
251
@@ -285,10 +273,12 @@ my-next-app/
285
273
-`layout.tsx`: Shared UI between routes (navbar, footer)
286
274
-`page.tsx`: Unique page content
287
275
- Add folders to create nested routes
276
+
-**Beginner Tip**: Think of `layout.tsx` as a wrapper that appears on multiple pages (like a template), while `page.tsx` is the unique content for each page
288
277
289
278
-**`public/`**: Store static files like images, fonts, or robots.txt
-**Beginner Tip**: Drop any image here and you can access it directly in your code like `<img src="/logo.png" />` - no import needed!
292
282
293
283
-**`next.config.js`**: Configure Next.js behavior
294
284
- Add redirects, rewrites, environment variables
@@ -297,12 +287,14 @@ my-next-app/
297
287
### Essential npm Scripts
298
288
299
289
```bash
300
-
npm run dev # Start development server (port 3000)
301
-
npm run build # Create optimized production build
302
-
npm run start # Start production server
303
-
npm run lint # Run ESLint to check code quality
290
+
npm run dev # Start development server (port 3000) - Use this while coding
291
+
npm run build # Create optimized production build - Run before deploying
292
+
npm run start # Start production server - Test your production build locally
293
+
npm run lint # Run ESLint to check code quality - Find code issues
304
294
```
305
295
296
+
**For Beginners**: During development, you'll mainly use `npm run dev`. This starts a local server with helpful error messages and hot reloading. Only use `npm run build` and `npm run start` when you want to test how your app will perform in production or before deploying.
297
+
306
298
## Learning Path & Next Steps
307
299
308
300
Now that you understand what Next.js is and why it's valuable, here's your learning roadmap:
@@ -367,7 +359,5 @@ Whether you're a beginner learning web development or an experienced developer l
367
359
368
360
In the next tutorial, we'll dive deeper into creating your first Next.js application, exploring the file-based routing system, and building your first pages. Get ready to experience the power and simplicity of Next.js!
369
361
370
-
:::tip
371
362
**Ready to Start Building?**
372
363
Run `npx create-next-app@latest` right now and follow along with the upcoming tutorials. The best way to learn is by doing! 🚀
0 commit comments